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

SA1137 is not raised #3910

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mivee
Copy link

@Mivee Mivee commented Dec 14, 2024

Issue URL: #3904

Collectionexpressions are detected as variable declarations and not as InitializerExpression.

Previously they where checked based on the declaration itself (so we only have 1 Item e.g. var myVariable = [1,2,3]) . Now, for collection initializations we get the SyntaxNode from the variable and then validate each item of the collection on its own.

Since this is my first open source contribution feedback is very welcome.

I also found 2 points where I'm not sure how to proceed with:

  • Microsoft.CodeAnalysis.CSharp is installed with V.1.2.1 @Stylecop.Analyzers. V.4.7.0 introduced the CollectionExpressionSyntax that would simply my IsCollectionExpression() to just a type check basiclly. Also the "workaround" with that id could be removed so imo it would be way cleaner, due to beeing 3 Major Versions behind i didnt wanted to update, since i basiclly dont know the project and also what could be affected by that upgrade.
  • locally StyleCop.Analyzers.Test.CSharp8.SpacingRules.SA1009CSharp8UnitTests.TestMissingTokenAsync failed due to having a different Windows language. A possible solution could be https://stackoverflow.com/questions/5793000/is-this-a-good-approach-for-temporarily-changing-the-current-threads-culture

Copy link

codecov bot commented Dec 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.44%. Comparing base (f5843ae) to head (d22f8a0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3910   +/-   ##
=======================================
  Coverage   97.44%   97.44%           
=======================================
  Files         926      932    +6     
  Lines      110283   110380   +97     
  Branches     3319     3320    +1     
=======================================
+ Hits       107467   107564   +97     
  Misses       1847     1847           
  Partials      969      969           

Collectionexpressions are detected as variable declarations and not as InitializerExpression

- Filter based on the declared variables collectionexpressions out, and then check each element
@Mivee Mivee force-pushed the issues/3904_SA1137_not_raised branch from 6481cc1 to d22f8a0 Compare December 20, 2024 13:17
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.

1 participant