Coder Social home page Coder Social logo

luhncheck's Introduction

Hi there! ๐Ÿ‘‹

I'm Myles (he/him). I write primarily in C# (with xUnit, Moq, and Coverlet/Codecov helping make sure I don't break what I've made), and am currently working on several projects to help me develop my skills.

Some of my recent projects:

  • TicketSystem - a test project simulating parts and task management for field engineers. Written using .NET Core 3.1.
  • PlayersToolkitFor13thAge - a project to develop a character sheet manager and general players' toolkit for the tabletop RPG 13th Age. Written using .NET Framework 4.7.2, initially using WinForms for a desktop implementation, with Tim Corey's C# course as a framework for the initial design of the desktop application.
  • LuhnCheck - a small programme to check input strings using the Luhn algorithm. Written using .NET Framework 4.7.2, looking to port it to .NET Core 3.1.
  • FederalRegisterClient - a simple client for retrieving Federal Register documents

Repo statuses

Project Build status Coverage
TicketSystem GitHub Workflow Status codecov
LuhnCheck GitHub Workflow Status codecov
PlayersToolkitFor13thAge GitHub Workflow Status codecov
FederalRegisterClient GitHub Workflow Status codecov

N.B. Above code coverage metrics do not include UI logic for respective projects.

luhncheck's People

Contributors

mylesftop avatar

Watchers

 avatar

luhncheck's Issues

Action fails on dotnet build and dotnet test due to missing reference assemblies

After repointing the working directory in the .NET build / test commands, they are failing due to the following error:

Run dotnet build --configuration Release

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.101

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 9.29 sec for /home/runner/work/LuhnCheck/LuhnCheck/ValidationCore/LuhnValidationUnitTests/LuhnValidationUnitTests.csproj.
/opt/hostedtoolcache/dncs/3.1.101/x64/sdk/3.1.101/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/home/runner/work/LuhnCheck/LuhnCheck/ValidationCore/LuhnLibrary/LuhnLibrary.csproj]
/opt/hostedtoolcache/dncs/3.1.101/x64/sdk/3.1.101/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/home/runner/work/LuhnCheck/LuhnCheck/ValidationCore/LuhnCheck/LuhnCheck.csproj]

Build FAILED.

/opt/hostedtoolcache/dncs/3.1.101/x64/sdk/3.1.101/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/home/runner/work/LuhnCheck/LuhnCheck/ValidationCore/LuhnLibrary/LuhnLibrary.csproj]
/opt/hostedtoolcache/dncs/3.1.101/x64/sdk/3.1.101/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/home/runner/work/LuhnCheck/LuhnCheck/ValidationCore/LuhnCheck/LuhnCheck.csproj]
    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:12.78
##[error]Process completed with exit code 1.

This seems to implicate the framework, so this may need to be specified in the setup.

Add unit test coverage to project

Adding unit test coverage to the project will help to check for any regressions as well as validating that the functions are working as intended.

Migrate LuhnCheck and LuhnLibrary to .NET Core

These have already been upgrade from .NET Framework 4.6.1 to 4.7.2, but they need to migrated to .NET Core (currently expected to target 3.1, in line with LuhnLibrary.Tests). This will probably be done first with LuhnLibrary by renaming it and then creating a new .NET Core project "behind" it (i.e. with it inheriting from the .NET Core project), and then gradually moving code over to the new project until the .NET Framework version can be dropped.

This is ideally done after measuring code coverage in issue #20.

Remove duplication in unit tests

Currently, the unit tests exhibit duplication in the code used by test methods. These can be simplified by extracting the parameters in the methods and passing them back as arguments to fewer methods.

luhnDigit is not reduced to a single digit at the end of the calculation

The luhn calculation function should finish by reducing the check value to a single digit, but currently just adds the weighted digit sum regardless of length (e.g. "123456789" should return a check digit of "7", but currently returns a check digit of "70").

No conditional logic will be required, as a single digit value just returns itself as the digit sum.

CalculateLuhnDigit does not reduce doubled digits that exceed 9

The algorithm in CalculateLuhnDigit() incorrectly presumes that the doubling operation can be performed with the sum of the relevant digits, but the Luhn algorithm proper will double each relevant digit in place, then reduce it to its digit sum; this produces a distinct result due to the reduction operation.

Complete coverage for CheckLuhnSuffixReturnString

Per issue #20, current coverage for LuhnLibrary is 88.9%, with only one method uncovered - CheckLuhnSuffixReturnString, which is essentially a wrapper for CheckLuhnSuffixReturnBool to return strings of "valid" or "not valid" instead of a boolean.

While the function is relatively trivial (I'm hesitant to compare literals if it doesn't affect the internal logic of the program - this is just standardising the output for re-use, so it's bordering on UI logic), it may be worth making sure that the function is returning a string to catch any regressions (even though the return type is right there in the method name).

Originally posted by @MylesFTOP in #20 (comment)

Extract instantiation to new class

Instantiation is currently duplicated in a few places, so needs to be extracted to a new class with a method that takes the desired object as an argument.

Luhn algorithm is not implemented correctly

Currently, the checksum algorithm implemented is a combination of digit sum (including doubling every other digit in the digit sum), and then a final digit sum to reduce the output to a single digit, but the Luhn algorithm itself includes functions to find the remainder of a mod 10 function (or to achieve a remainder of 0 from a mod 10 function). The function will need to be rewritten to implement this correctly.

Abstract current use case to AddSuffix method

The current method using CalculateLuhnDigit() only implements adding a calculated suffix. This needs to be made explicit by abstracting an AddSuffix() method that calls CalculateLuhnDigit() to calculate the suffix it needs to add.

Add code coverage metrics using Coverlet and Codecov

This will initially be sourced from the local build and targeted at LuhnLibrary, and then later extracted into the workflow for automating in actions, before later adding LuhnLibrary.Tests in the coverage metrics (to make sure tests are being exercised).

Make command line interface more explicit

Currently, the command line interface doesn't echo any text to the user, only provides an input . This needs to provide:

  • A function selection prompt, and;
  • A string input prompt once the function has been selected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.