-
Notifications
You must be signed in to change notification settings - Fork 511
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
SA1501 applied differently when used in .editorconfig vs .ruleset #3290
Comments
Well that's weird 😄 Note that .globalconfig is a better replacement for rule sets than .editorconfig. Have you tried moving the configuration there? |
I am experiencing the same problem. Moving the settings from a ruleset to an .editorconfig doesn't seem to work at all. |
Rule SA1501 depends on the configuration for SA1503 source
But even with this file, I can only get SA1501 to fire on
but not on
Indicating that somehow it doesn't detect SA1503 is suppressed. |
Due to the way configuration is checked, these rules may need to be configured via .globalconfig (from my earlier comment) and not via .editorconfig in order for the relation between SA1501 and SA1503 to be detected during analysis. While such a requirement would not be intentional, do note that .globalconfig (and not .editorconfig) is the true replacement for .ruleset files. |
I can confirm that renaming the file to .globalconfig and removing the section header, the SA1501 fires in both cases. |
Yes, this implementation detail is specific to the way StyleCop Analyzers tries to link/coordinate the behavior of SA1501 and SA1503. In hindsight this wasn't a great idea but removing the link between the two is difficult now. Now that the repository has proper support for .editorconfig (#3285), the implementation of these two rules could be updated to work with both .editorconfig and .globalconfig. |
There's this piece of code
Before.
I used to use the
.ruleset
file in the past to set up the analyzers.That setup would result in this:
![image](https://user-images.githubusercontent.com/7033216/104688101-bef0ca00-5700-11eb-8342-a099a0bef883.png)
After.
I have since migrated to the
.editorconfig
, removed the.ruleset
entry from thecsproj
file and I now have this:Now, this situation is no longer detected.
![image](https://user-images.githubusercontent.com/7033216/104688703-81d90780-5701-11eb-97d3-ecba3b9bfe18.png)
While I understand that SA1501 may not even deal with this particular case, as the
cause
for theSA1501
as per docs requires braces to be present, I don't understand why it works differently with the.ruleset
file and not with the.editorconfig
.I am mostly interested in a rule that would (regardless of the braces) disallow putting
return/continue/break
on the same line as any other flow control statement (if, while, etc.). Is there any such rule that can be used with the.editorconfig
?💻 Technical context
The text was updated successfully, but these errors were encountered: