Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt inferred variable types (var) to enhance code readability and maintainability #141

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

DennisDyallo
Copy link
Collaborator

Description

Now using inferred variable types (var) instead of explicit types in all projects except Yubico.Core. This change aims to improve code readability, reduce verbosity, and enhance developer productivity while maintaining type safety.

Key points:

  • Improved readability: Using 'var' can make code more concise and easier to read, especially with long or complex type names.
  • Reduced redundancy: 'var' eliminates the need to repeat type information that's already clear from the right-hand side of the assignment.
  • Easier refactoring: When types change, using 'var' means fewer places in the code need to be updated.
  • Consistency with modern C# practices: Many contemporary C# codebases and style guides recommend using 'var' where the type is obvious.
  • Faster coding: Typing 'var' is quicker than writing out full type names, speeding up the development process.
  • Encourages descriptive variable names: With type information inferred, developers are more likely to use clear, descriptive variable names.

Exclusion of Yubico.Core:
I excluded Yubico.Core from this change initially due to its extensive use of interop code and custom structs. This cautious approach allows us to implement the change gradually and assess its impact before applying it to more complex areas of the codebase.

By adopting 'var' in most of our projects, we aim to modernize our codebase, improve developer productivity, and enhance code maintainability while still maintaining the robustness and clarity of our type system.

Type of change

  • Refactor (non-breaking change which improves code quality or performance)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Unit tests in Yubico.Yubikey passed locally.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have run dotnet format to format my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link

github-actions bot commented Aug 14, 2024

Test Results: Windows

    2 files      2 suites   5s ⏱️
3 703 tests 3 703 ✅ 0 💤 0 ❌
3 705 runs  3 705 ✅ 0 💤 0 ❌

Results for commit 6b971e6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 14, 2024

Test Results: Ubuntu

    2 files      2 suites   10s ⏱️
3 695 tests 3 695 ✅ 0 💤 0 ❌
3 697 runs  3 697 ✅ 0 💤 0 ❌

Results for commit 6b971e6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 14, 2024

Test Results: MacOS

    2 files      2 suites   4s ⏱️
3 695 tests 3 695 ✅ 0 💤 0 ❌
3 697 runs  3 697 ✅ 0 💤 0 ❌

Results for commit 6b971e6.

♻️ This comment has been updated with latest results.

Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
Yubico.Core 42% 32% 4179
Yubico.YubiKey 50% 47% 19110
Summary 49% (32077 / 65925) 44% (8197 / 18549) 23289

Minimum allowed line rate is 40%

@DennisDyallo DennisDyallo merged commit e1dbe19 into develop Aug 14, 2024
11 checks passed
@DennisDyallo DennisDyallo deleted the dennisdyallo/implicit-var branch August 14, 2024 16:57
@DennisDyallo DennisDyallo added the enhancement New feature or request label Aug 14, 2024
@DennisDyallo DennisDyallo self-assigned this Aug 14, 2024
This was referenced Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

1 participant