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

Collection expressions (IDE0300) #6726

Closed
wants to merge 7 commits into from

Conversation

glen-84
Copy link
Collaborator

@glen-84 glen-84 commented Nov 27, 2023

Summary of the changes (Less than 80 chars)

  • Updated code triggering IDE0300 to use collection expressions.

This handles all but 2 cases of IDE0300. The handled cases should be non-controversial (?). The remaining 2 cases are more subjective – do you have a preference for keeping the explicit types in the examples below?

-       _handlers = new ITypeRegistrarHandler[]
+       _handlers =
-       {
+       [
            new ExtendedTypeReferenceHandler(context.TypeInspector),
            new SchemaTypeReferenceHandler(),
            new SyntaxTypeReferenceHandler(context.TypeInspector),
            new FactoryTypeReferenceHandler(context),
            new DependantFactoryTypeReferenceHandler(context),
            new ExtendedTypeDirectiveReferenceHandler(context.TypeInspector)
-       };
+       ];
    public OffsetDateTimeType() : this(OffsetDateTimePattern.ExtendedIso)
    {
        // Backwards compatibility with the original code's behavior
        _serializationPattern = OffsetDateTimePattern.GeneralIso;
-       _allowedPatterns = new IPattern<OffsetDateTime>[] { OffsetDateTimePattern.ExtendedIso };
+       _allowedPatterns = [OffsetDateTimePattern.ExtendedIso];
    }

The pros of updating them:

  • Terser code.
  • Analyzer IDE0300 can be fully enforced without exceptions.

The cons:

  • Some developers may consider the explicit types to be more readable/understandable.

Since I could only find 2 examples within the entire codebase, it might make sense to just update these as well, and then enable the analyzer (and consider also using EnforceCodeStyleInBuild).

Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (8bf1558) 70.16% compared to head (b9212c6) 70.20%.
Report is 1 commits behind head on main.

❗ Current head b9212c6 differs from pull request most recent head b5861c9. Consider uploading reports for the commit b5861c9 to get more accurate results

Files Patch % Lines
...ore/src/Transport.Http/DefaultGraphQLHttpClient.cs 73.68% 5 Missing ⚠️
...tCore/Extensions/EndpointRouteBuilderExtensions.cs 84.21% 3 Missing ⚠️
...ons/HotChocolateAuthorizeRequestExecutorBuilder.cs 0.00% 1 Missing ⚠️
...rc/AspNetCore/Extensions/HttpResponseExtensions.cs 0.00% 1 Missing ⚠️
...rc/AspNetCore/Subscriptions/WebSocketConnection.cs 0.00% 1 Missing ⚠️
...re/src/Abstractions/GraphQLNonNullTypeAttribute.cs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6726      +/-   ##
==========================================
+ Coverage   70.16%   70.20%   +0.04%     
==========================================
  Files        2485     2485              
  Lines      125521   125521              
==========================================
+ Hits        88067    88118      +51     
+ Misses      37454    37403      -51     
Flag Coverage Δ
unittests 70.20% <93.06%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@michaelstaib michaelstaib self-requested a review November 27, 2023 11:58
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@github-actions github-actions bot added 📚 documentation This issue is about working on our documentation. 🧰 maintenance labels Jan 22, 2024
@glen-84 glen-84 marked this pull request as draft January 22, 2024 14:58
@glen-84 glen-84 force-pushed the collection-expressions branch from b9212c6 to 192f5ea Compare January 22, 2024 15:23
@github-actions github-actions bot removed 📚 documentation This issue is about working on our documentation. 🧰 maintenance labels Jan 22, 2024
@michaelstaib michaelstaib marked this pull request as ready for review January 22, 2024 20:57
@glen-84
Copy link
Collaborator Author

glen-84 commented Jan 23, 2024

Superseded by #6845.

@glen-84 glen-84 closed this Jan 23, 2024
@glen-84 glen-84 deleted the collection-expressions branch January 23, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant