-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove redundant assignment #5649
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually really like this change because I think it will make it much more obvious when we try to set a default value for something and accidentally don't overwrite it. Would you mind resolving my comments (especially with moving declarations into definitions with out)? Thanks!
src/Build.UnitTests/Definition/ToolsetConfigurationReader_Tests.cs
Outdated
Show resolved
Hide resolved
src/Build/BackEnd/Components/RequestBuilder/TargetUpToDateChecker.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'd still like to see the patterns of the form:
<type> <name>;
<functionCall>(<param0>, <param1>, out <name>);
or equivalent translated into
<functionCall>(<param0>, <param1>, out <type> <name>);
But we can save that for later.
I can do another refactor PR for that. There are a lot of changes like that so it will be easier to review in a separate issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't gone through everything, but here's some feedback based on what I've seen so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed half and then got tired and gave it up. As long as the class of issues that I commented on get fixed, looks good to me.
Since these big repetitive changes suck the life out of reviewers, maybe we should have a contribution rule where we restrain these types of changes somehow. Thinking out loud, one strategy would be to only allow them on the files touched by a PR that has a meaningful feature addition / bug fix change, or some other throttling mechanism. We could also define a set of linters to use and/or config files for them (resharper, VS, roslynator, etc)
| string oldestOutput = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(outputs[0].ToString())); | ||
| ErrorUtilities.ThrowIfTypeDoesNotImplementToString(outputs[0]); | ||
|
|
||
| DateTime oldestOutputFileTime = DateTime.MinValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this, older version seems more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oldestOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime returns "The last write time of the file, or DateTime.MinValue if the file does not exist". So we don't need to assign DateTime.MinValue. Additionally the try catch also assigns it. Same thing with candidateOutputFileTime. I've added it back in for you though.
Thanks for getting so far. I will create an issue to look at copying the Anlyzers and config from the dotnet/runtime codebase. |
That would cool, thanks! It would also be cool if we had a bot which adds a commit to every PR with the rules applied to the changed files. That would trickle the changes in a more digestible manner. Alternatively, we could also just apply everything in one humongous PR (maybe linting + formatting), and then have a few weeks of stabilization where we check that nothing regressed. And after that have a bot apply them to each PR. |
Here is the issue #5655. |
|
Team triage: We're also thinking that we might use #5656 as a checklist to measure progress towards a nicely refactored repo, in which case you can put the lint ID you're addressing in the title to make it easy to find. We should have a separate team meeting to discuss what rules we want to keep and which we might discard, though, and we haven't had that yet. We'll get back to you when that happens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed it wasn't necessary to have these two assignments, but it made a little clearer what was going on. If I see an arbitrary int, for instance, that tells me very little about it. Seeing that there's something called a BuildRequest, and this is an ID for a build makes that a lot clearer.
Thanks for making this change! I'm really glad you did.
Refactoring to remove redundant assignments.
https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1212.md