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

#1660 Huge logs because of StyleCop.Analyzers warnings #1663

Merged
merged 56 commits into from
Jun 4, 2023
Merged

Conversation

raman-m
Copy link
Member

@raman-m raman-m commented Jun 1, 2023

Fixes #1660

A long list of StyleCop.Analyzers warnings in build logs: CircleCI, VS Output Build, VS Error List Warnings.

Proposed Changes

  • Add StyleCop.Analyzers package to Ocelot.Provider.Kubernetes, Ocelot.Tracing.Butterfly, Ocelot.Tracing.OpenTracing
  • Fix SA* StyleCop warnings
  • Fix CA* C# Styling warnings
  • Fix CS* C# warnings
  • Fix IDE* C# errors, warnings and info
  • Upgrade Basic and K8s samples to ASP.NET 7 to fix warnings and apply ASP.NET 7 MVC templates

raman-m added 30 commits May 30, 2023 19:14
…tion, whenever the parameter span across multiple lines
@raman-m raman-m self-assigned this Jun 1, 2023
@raman-m raman-m added bug Identified as a potential bug feature A new feature accepted Bug or feature would be accepted as a PR or is being worked on in progress Someone is working on the issue. Could be someone on the team or off. labels Jun 1, 2023
@raman-m raman-m requested a review from RaynaldM June 1, 2023 09:58
@raman-m
Copy link
Member Author

raman-m commented Jun 1, 2023

@RaynaldM Hey Ray!
Could you review my PR please?

/// </summary>
private readonly string[] _unsupportedRequestHeaders =
{
"Transfer-Encoding"
"Transfer-Encoding",
Copy link
Collaborator

Choose a reason for hiding this comment

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

comma is useless

Copy link
Member Author

Choose a reason for hiding this comment

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

This is SA1413 StyleCop rule. See more below!

@@ -82,7 +82,7 @@ private static async Task MapAggregateContent(HttpContext originalContext, List<

var stringContent = new StringContent(contentBuilder.ToString())
{
Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
Headers = { ContentType = new MediaTypeHeaderValue("application/json") },
Copy link
Collaborator

Choose a reason for hiding this comment

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

comma is useless

Copy link
Member Author

Choose a reason for hiding this comment

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

In the previous version (target):

image

This is SA1413 StyleCop rule.

Cause

The last statement in a multi-line C# initializer or list is missing a trailing comma.

Rationale

This rule is specifically designed to work well with the most widely used source control systems as an aid to long-term
code review. By placing a comma on the last line of a multi-line sequence, developers who append an item to the list or reorder the list at some point in the future will not need to modify any more lines than absolutely necessary for the
change. As a result, the size of the subsequent code review is minimized and focused, and tools like git blame
continue to show the original author and commit for the item that was previously last in the list.

I believe the most importand part of the Rationale is:

and focused, and tools like git blame
continue to show the original author and commit for the item that was previously last in the list.

So, the restriction of git compare/diff tool is tracking changes per line. That's why this rule was introduced in StyleCop Analyzer. The history of the line should not be overridden by absent comma if the next line will be changed in future.
Yeah, now I have overridden the author of this line. But that's how to fix it.
That's why I fixed the violation of SA1413 rule.

Finally,
I believe this is not a major issue to fix, but thank you for your comment!

@raman-m raman-m requested a review from TomPallister June 1, 2023 15:19
@raman-m
Copy link
Member Author

raman-m commented Jun 1, 2023

@RaynaldM Ray,
Thanks for the review!

@TomPallister Tom,
I will appreciate your review with merging to develop, please!
You could focus on "Upgrade XXX to ASP.NET 7" commits, which is the most interesting part of the PR! 😉

@raman-m raman-m removed the in progress Someone is working on the issue. Could be someone on the team or off. label Jun 1, 2023
@TomPallister TomPallister merged commit 6ca54fe into develop Jun 4, 2023
@TomPallister TomPallister deleted the bug-1660 branch June 4, 2023 14:13
@raman-m raman-m added the merged Issue has been merged to dev and is waiting for the next release label Jun 28, 2023
raman-m added a commit that referenced this pull request Sep 19, 2023
* push code coverage for main and develop branches

* #1660 Huge logs because of StyleCop.Analyzers warnings (#1663)

* Add StyleCop.Analyzers package

* Fix SA0001: XML comment analysis is disabled due to project configuration

* Fix SA1609: Property documentation should have value

* Fix CS1591: Missing XML comment for publicly visible type or member {xyz}

* Fix SA1101: Prefix local calls with this

* Fix SA1413: The last statement in a multi-line C# initializer or list is missing a trailing comma.

* Fix SA1135: A using directive is not qualified.

* Fix compiler errors

* Fix SA1651: Do not use placeholder elements

* Fix compiling error

* Fix SA1113: Comma should be on the same line as previous parameter

* Fix SA1116: The parameters should begin on the line after the declaration, whenever the parameter span across multiple lines

* Fix SA1137: Elements should have the same indentation

* Fix SA1200: Using directive should appear within a namespace declaration

* Fix SA1316: Tuple element names should use correct casing

* Fix SA1503: Braces should not be omitted

* Fix SA1505: An opening brace should not be followed by a blank line

* Fix SA1507: Code should not contain multiple blank lines in a row

* Fix SA1508: A closing brace should not be preceded by a blank line

* Fix SA1512, SA1515

* Fix SA1513: Closing brace should be followed by blank line

* Fix SA1400: Element 'OpenTracingTracer' should declare an access modifier

* Fix SA1515: Single-line comment should be preceded by blank line

* Fix SA1518: File is required to end with a single newline character

* Add StyleCop

* Fix SA1633: A C# code file is missing a standard file header.

* Disable SA1602: An item within a C# enumeration is missing an Xml documentation header.

* Fix SA1600: Elements should be documented

* Fix SA1604: Element documentation should have summary

* Fix SA1618: The documentation for type parameter 'T' is missing

* Fix SA1629: Documentation text should end with a period.

* Fix SA1649: File name should match first type name

* Fix SA1600: Elements should be documented

* Upgrade K8s sample to ASP.NET 7.
Rename project to Ocelot.Samples.OcelotKube.DownstreamService

* Upgrade K8s sample to ASP.NET 7.
Rename project to Ocelot.Samples.OcelotKube.ApiGateway

* Fix CS0169: The field 'xxx' is never used

* Fix CS0219: The variable 'baseUrl' is assigned but its value is never used

* Fix CS0414: The field 'xxx' is assigned but its value is never used

* Fix CS1570: XML comment has badly formed XML

* Fix CS0649: Field 'xxx' is never assigned to, and will always have its default value null

* Fix CS0618: 'member' is obsolete: 'text'

* Fix NU1504: Duplicate 'PackageReference' items found: Microsoft.Data.SQLite 7.0.4, Microsoft.Data.SQLite 7.0.5

* Upgrade sample to ASP.NET 7

* Fix NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated.
Consider using the 'PackageIcon'/'icon' element instead.
Learn more at https://aka.ms/deprecateIconUrl

* Rewrite a RequestDelegate object definition

* Fix CS0618: 'member' is obsolete: 'text'

* Fix CA1816: Change Dispose() to call GC.SuppressFinalize(object).
This will prevent derived types that introduce a finalizer from needing to re-implement 'IDisposable' to call it.

* Fix CA1822: Member 'GivenThereIsAConfiguration' does not access instance data and can be marked as static

* Fix CA1837: Use 'Environment.ProcessId' instead of 'Process.GetCurrentProcess().Id'

* Fix CA2211: Non-constant fields should not be visible.
Convert to property.

* Fix IDE0060: Remove unused parameter 'path' if it is not part of a shipped public API

* Fix CA1816: Change ConsulWebSocketTests.Dispose() to call GC.SuppressFinalize(object).

* Fix IDE1006: Naming rule violation: These words must begin with upper case characters

* Fix IDE1006: Naming rule violation: These words must begin with upper case characters: AcceptanceTests\WebSocketTests

* Fix last issues

* Upgrade basic sample to ASP.NET 7

* fixed up required spacing in README (#1499)

Co-authored-by: Justin Middler <[email protected]>

* Update README.md

---------

Co-authored-by: TomPallister <[email protected]>
Co-authored-by: Justin Middler <[email protected]>
Co-authored-by: Justin Middler <[email protected]>
Co-authored-by: Tom Pallister <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Bug or feature would be accepted as a PR or is being worked on bug Identified as a potential bug feature A new feature merged Issue has been merged to dev and is waiting for the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Huge logs because of StyleCop.Analyzers warnings
3 participants