Skip to content

Conversation

kamikkels
Copy link
Contributor

Moving the solution to using Primary constructors and collection expressions as per issue #520

  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • 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
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

@kamikkels kamikkels requested a review from siriak as a code owner October 2, 2025 02:37
@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 02:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the codebase by migrating to C# 12 primary constructors and collection expressions, replacing traditional constructors and array initialization syntax with their more concise modern equivalents.

  • Replaces traditional constructors with primary constructor syntax
  • Updates array initializations from new[] { } syntax to collection expressions [ ]
  • Converts constructor parameter assignments to property initializers

Reviewed Changes

Copilot reviewed 75 out of 75 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Utilities.Tests/Extensions/MatrixExtensionsTests.cs Updates test data arrays to use collection expressions
DataStructures/UnrolledList/UnrolledLinkedListNode.cs Converts to primary constructor with property initializers
DataStructures/UnrolledList/UnrolledLinkedList.cs Migrates to primary constructor pattern
DataStructures/SortedList.cs Updates constructor to primary constructor syntax
DataStructures/SegmentTrees/SegmentTreeUpdate.cs Converts to primary constructor pattern
DataStructures/ScapegoatTree/Node.cs Migrates to primary constructor with property initializers
DataStructures/RedBlackTree/RedBlackTreeNode.cs Updates to primary constructor pattern
DataStructures/LinkedList/SkipList/SkipListNode.cs Converts to primary constructor syntax
DataStructures/LinkedList/SinglyLinkedList/SinglyLinkedListNode.cs Migrates to primary constructor pattern
DataStructures/LinkedList/DoublyLinkedList/DoublyLinkedListNode.cs Updates to primary constructor syntax
DataStructures/Heap/PairingHeap/PairingNodeComparer.cs Converts to primary constructor pattern
DataStructures/Heap/PairingHeap/PairingHeapNode.cs Migrates to primary constructor syntax
DataStructures/Heap/PairingHeap/PairingHeap.cs Updates to primary constructor pattern
DataStructures/Hashing/Entry.cs Converts to primary constructor syntax
DataStructures/Cache/LruCache.cs Migrates to primary constructor pattern
DataStructures/Cache/LfuCache.cs Updates to primary constructor syntax
DataStructures/BitArray.cs Converts array initialization to collection expression
DataStructures/BinarySearchTree/BinarySearchTreeNode.cs Migrates to primary constructor pattern
DataStructures/AVLTree/AVLTreeNode.cs Updates to primary constructor syntax
DataStructures/AATree/AATreeNode.cs Converts to primary constructor pattern
DataStructures/AATree/AATree.cs Migrates to primary constructor syntax
Various test files Updates test arrays to use collection expressions
Algorithm files Migrates classes to primary constructors and updates array initializations
Comments suppressed due to low confidence (2)

DataStructures/AATree/AATree.cs:1

  • [nitpick] The parameterless constructor is redundant since it only sets the comparer to the default value. Consider creating a second primary constructor that uses Comparer.Default as the default parameter value instead of maintaining two constructors.
using System;

DataStructures/SortedList.cs:1

  • [nitpick] The parameterless constructor is inconsistent with the primary constructor pattern used elsewhere in this PR. Consider removing this constructor and using a default parameter value in the primary constructor instead.
using System.Collections;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 99.43503% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.61%. Comparing base (b47cdc9) to head (d773e0a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
Algorithms/Sorters/Comparison/BasicTimSorter.cs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #532      +/-   ##
==========================================
+ Coverage   95.22%   96.61%   +1.38%     
==========================================
  Files         274      274              
  Lines       10910    10835      -75     
  Branches     1535     1535              
==========================================
+ Hits        10389    10468      +79     
+ Misses        397      232     -165     
- Partials      124      135      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…odebase

Add tests for `AStar` and related classes to validate A* algorithm functionality.
@siriak
Copy link
Member

siriak commented Oct 2, 2025

Looks good, but please fix Codacy issues before I can merge

@kamikkels
Copy link
Contributor Author

I think the remaining medium is more of a false positive than anything else,
it doesn't really make sense to make VecN generic, so we can't really make it inherit IEquatable<T> but it does need to override Equals so we're trapped between Codacy and CA1066

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit 79497a6 into TheAlgorithms:master Oct 4, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants