-
-
Notifications
You must be signed in to change notification settings - Fork 336
Fix CA2000, CA2237, CA3075 #67
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
92da523
to
fb3b0fc
Compare
@@ -1409,7 +1429,10 @@ virtual protected void OpenFile(string fileName, bool append) | |||
/// </remarks> | |||
virtual protected void SetQWForFiles(Stream fileStream) | |||
{ | |||
SetQWForFiles(new StreamWriter(fileStream, m_encoding)); | |||
#pragma warning disable CA2000 // Dispose objects before losing scope |
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 think we should refactor this somehow.
@NicholasNoise I'm all for trying to up code quality; this adds a ton of noise though. For me, warnings are a thing that should not be seen -- all warnings should be attended to, either by solving the problem the warning is about or by intentionally suppressing the warning. Perhaps FxCop isn't the way to go? Perhaps we should look at something like SonarQube? It's equally noisy, but not in the build. Also, FYI,
Took me a while to find it in the swathes of warnings. |
fb3b0fc
to
cb49b6f
Compare
@fluffynuts Every warning you see may be (or should be) turned off by ruleset: some warning are essential and should be attended to, others are not and just ignore them with no regret. Anyway you are right that pushing a warning-free project into the dirt is no good.
|
That sounds like a good plan 👍 |
btw, I don't have anything against FxCop, and I expect rules would have to be established, just like for SonarQube; I guess I'm just remembering how successful SonarQube was for me on one of my projects because I could chip away at warnings one by one until I got a clean bill of health without interfering with build elsewhere. I don't know enough about FxCop to be sure, but I'd expect that we could perhaps enable rule processing for a specific build configuration only -- and have that build configuration targeted by Don't be afraid of an external tool though -- it can always be made part of the build pipeline. That's not a bump for or against any particular tool -- just a note. |
cb49b6f
to
3941383
Compare
Done!
Two ruleset is the way to get things done (:
Build-in tools are preferable, an external tool makes it harder for new contributor to join. But in the same time used tools should be effective by all means. |
I'm not talking about expecting people to install stuff -- external tools which can be bootstrapped by the build pipeline are ok -- for instance, running tests: for the primary run, we use the nunit runner, but how that happens is all tucked away in the bowels of
will
At some point, I want to automate the site into that (I have a The point is: I don't mind external stuff which can be automated. I try to reduce non-automatable dependencies, which should be documented (yes, I have work to do there too, in cleaning up the docs). |
@NicholasNoise I need to ask you for one more change before merging: the style of the project has been to use spaces for indentation. I noticed some whitespace changes on the prior PRs and just left it, but I'd really appreciate it if you could use spaces instead of tabs in this project. Perhaps I should set up an .editorconfig to assist with this... |
One more reason to use something like StyleCop to prevent from happening. |
hm, I don't mind, really, what style is adopted -- in the file where I saw whitespace changes, it looked like the original code was spaces and your changes were tabs. Now I'd like to get an overview: whilst my preference is for spaces in C# (it's the default style, and I'm about adopting default styles instead of bucking them), I understand how tabs can be beneficial to the few people who care to set up configuration for them (: StyleCop isn't enough -- a contributor may use something other than Visual Studio or a ReSharper-aware IDE (personally, I use Rider, but there's a case for VSCode, or whatever someone wants to use) to edit code. Most decent editors should understand .editorconfig and assist the user to maintain correct style without them having to respond to warnings. I'm sure StyleCop can do more too, so perhaps it could be used in conjunction with an .editorconfig. There are a lot of conventions which can be configured via .editorconfig, in addition to simpler things like indentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2019 I think I'll just accept what you have here (because the fixes are good) and mull over (a) what the style should be and (b) how to help to enforce it (: |
I prefer spaces too by its looks-the-same-everywhere feature.
StyleCop and FxCop grant a build validation with right ruleset (SA1027 set to Error), so it is IDE independent.
Thanks! |
Is 2.0.11 planned to release any time soon? |
I've started a vote, have one +1, so waiting on 2 more. |
What I mean is that StyleCop is a "you broke it, so you need to fix it" solution -- a gate, if you will, which is good, but better is something which informs the editor of the correct choice to make so that when the coder presses , the right thing is done and the coder doesn't have to retroactively fix things or update their IDE prefs to fit in with StyleCop. EditorConfig provides this. IOW, StyleCop is retroactive where editorconfig is proactive. Keep the retroactive to enforce style, bit provide the proactive to make it not the problem of the new contributor to get it right (: Editorconfig was enough to get my team all on the same page across win/osx for another project - no errors or warnings, just editors fixing styles as people worked. Anyway, it's all academic until I get some time to add a .editorconfig. I would welcome a StyleCop PR though - I don't use it, so wouldn't know offhand how to set it up. My opinion is that we should be helping contributors to make meaningful contributions with as little resistance as possible. |
@NicholasNoise 2.0.11 is out with these changes. Things take a little while because:
|
@NicholasNoise if you're interested in (3), let me know how to contact you. Your GitHub profile has no contact info ): |
Thanks!
There is no problem at all, I've saw insides of how-to-release-project - is not that simple as it looks. @fluffynuts |
yeah, I need to update that too, because quite a bit of helpful contributor documentation is out of date ): |
Fix CA2000, CA2237, CA3075
Also requires #66 otherwise nuget restore fails.