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

Resolved more warnings, and marked more warning types as errors #16991

Merged
merged 18 commits into from
Sep 24, 2024

Conversation

emmagarland
Copy link
Contributor

@emmagarland emmagarland commented Sep 1, 2024

Prerequisites

  • I have added steps to test this contribution in the description below

Continuing on from #16990

If there's an existing issue for this PR then this fixes some of #15015

Description

Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).

Fixed various warnings where they are more straight-forward, including:

  • SA1111/SA1116/SA1119 parenthesis formatting
  • SA1117 params formatting
  • SA1312/SA1306 lowercase variables and field names
  • SA1121 built-in type
  • SA1500/SA1513/SA1503 formatting braces
  • SA1400 declare access modifier
  • SA1122 string.Empty
  • SA1310 no underscore
  • SA1649 filename match type name
  • IDE0049 name simplified
  • IDE0057 simplify substring
  • IDE0074 compound assignment
  • IDE0032 use auto-property
  • IDE0037 simplify member name
  • IDE0008 explicit type not var
  • IDE0016/IDE0270/IDE0041 simplify null checks
  • IDE0048/SA1407 clarity in arithmetic
  • IDE1006 params naming rule violation
  • IDE0042 deconstruct variable
  • IDE0044 make field readonly
  • IDE0018 inline variable declarations
  • IDE0074/IDE0054 compound assignment
  • IDE1006 naming
  • CS1573 param XML
  • CS0168 unused variable

Comment formatting in project files for consistency.

To test, ensure solution builds, tests and runs as expected. Worth scanning the files changes to ensure no likely issues I've not considered.

Currently seeing 8617 solution-wide warnings (this needs verification)

#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete

CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty

Down to 3479 warnings
- IDE0057 substring simplified

Specific warnings for Umbraco.Tests.Benchmarks
Fixed:

- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
@emmagarland emmagarland changed the title [AFTER 16990] Resolved more warnings (part of overall goal warnings as errors in #15015) [AFTER 16990] Resolved more warnings (part of #15015) Sep 1, 2024
Copy link

github-actions bot commented Sep 1, 2024

Hi there @emmagarland, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@emmagarland emmagarland added community/pr category/dx Developer experience labels Sep 1, 2024
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check

Updated the following projects to only list their remaining specific warning codes:

- Umbraco.Tests.UnitTests

Typo in `Umbraco.Web.Website` project
@georgebid
Copy link
Contributor

And I will also look at this one when you are finished with it 😺

@emmagarland emmagarland changed the title [AFTER 16990] Resolved more warnings (part of #15015) [AFTER 16990] Resolved more warnings, and marked more warning types as errors Sep 2, 2024
Fixed various warnings where they are more straight-forward, including:

- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable

Comment formatting in project files for consistency.

Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
@emmagarland
Copy link
Contributor Author

emmagarland commented Sep 3, 2024

@georgebid think I'm finished with this so far, but I won't publish till the other is merged since I branched off that one (fewer files to read!).

Some Codescene warnings are because the files got bigger due to formatting changes etc.

@georgebid georgebid self-assigned this Sep 5, 2024
@georgebid
Copy link
Contributor

@emmagarland The other is merged now so feel free to edit and let me know when this one is ready to be looked at 😸

@emmagarland emmagarland changed the title [AFTER 16990] Resolved more warnings, and marked more warning types as errors Resolved more warnings, and marked more warning types as errors Sep 10, 2024
@emmagarland
Copy link
Contributor Author

@georgebid Coolio, thanks, I'll let you know when it's all ready! 😃

@emmagarland emmagarland marked this pull request as ready for review September 12, 2024 10:34
@emmagarland
Copy link
Contributor Author

@georgebid I've now merged from contrib and tweaked a few merge issues and comments locations. I've built and run locally, so it's now ready for review.

Again, Codescene is not happy that I've increased the length of things by updating the formatting according to the Stylecop guidelines etc, but I don't think that can be helped at this stage.

It would also be good to know what you get for number of warnings on this branch (and possibly contrib). I'm not getting consistent numbers atm.

Let me know if any questions!

@georgebid
Copy link
Contributor

Hey @emmagarland, I have just built and run all fine - I am seeing 10066 warnings in my solution, which seems to be a few more than you, does that still feel like a decrease from before? I tried a clean and build a couple of times too but yeah, 10066 for me! I'm happy to merge though if you're happy with that!

@emmagarland
Copy link
Contributor Author

Thanks @georgebid ; that sounds like it's the right number, I think my build is just not updating the number as there are many! Hopefully now they won't be added to as we reduce more errors/warnings. If you're happy to merge feel free to go for it - thanks so much!

@georgebid georgebid merged commit ac57566 into umbraco:contrib Sep 24, 2024
13 of 14 checks passed
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.

3 participants