-
Notifications
You must be signed in to change notification settings - Fork 508
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
SA1005 does not allow indentation of comments #715
Comments
I don't have an answer for you yet, but I have some additional notes on this situation.
|
Well, perhaps if we had an SX1005 rule, it would be to require at least one space, but allow more than one. |
Do you happen to know what the reference version of StyleCop does for this case? @vweijsters @pdelvo I believe you both have it installed for testing these things? |
Btw you can "install" StyleCop by installing the StyleCop.MsBuild nuget package. No system wide installation needed. |
@pdelvo I'm moving this to a bug based on that. |
The StyleCop source code is documented with these comments that don't seem to be handled by the implementation here:
|
We usually implement these rules the way the (bad) stylecop documentation describes them. This is why there are these differences. Comments starting with /// or //// are already ignored by this rule and the other stuff should be trivial to implement as well. Do you know why //\ and //-- are ignored? |
@pdelvo Working from the documentation sounds reasonable, though I do have some reservations with this approach. Lots of us finding this project are no doubt interested because of having a large code base that uses StyleCop - so it's important that the migrated rules match the behaviour of the "original" as closely as possible. I've no idea why //\ is ignored. I wonder if it's because patterns like //----------- and ////// are sometimes used as "dividers" in code, though the latter isn't very pretty! The reason why I started looking into this rule is that our standard file header causes a violation. The original StyleCop SA1005 doesn't check the file header, because that's covered by more specific rules instead. I've started experimenting with adjusting the code more closely to match the SC implementation. I don't know how far I'll get with this, mind you! In general, if the actual SC behaviour is different from what is documented, how do you usually decide which behaviour to migrate? |
Just stopping in to say welcome to the project @oatkins and thanks for taking a closer look at this issue. 👍 |
We try to do what makes the most sense to us.I personally think we should implement the following:
@oatkins What do you think? What does your file header look like? Would there still be a problem if we would change the rules like that? |
@pdelvo My large codebases that are migrating have similar headers to @oatkins by the sounds of it. Here is a sample of mine: //-----------------------------------------------------------------------
// <copyright file="HandsOffService.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//----------------------------------------------------------------------- But I think the best route would be for this rule to exclude any validation of header comments (which I suppose just means the first block of comments at the top of the file). As for your proposed alteration, the rules look roughly the same as what @oatkins listed earlier. Can you highlight the differences for us? |
I removed the //\ rule because I dont like it. |
In that case, it isn't important enough for me to push for at this point. But if the old implementation ignores headers and the new doesn't, it sounds like a new issue might be filed in the future by someone who hits a compact issue. But I don't mind waiting for that to maybe happen before we put in more work. |
Interestingly, SC's parser has a |
No we have to implement the file header stuff from scratch. The file header diagnostics are going to be a lot of work and this exception might be a freebie when we implement SA1633-SA1641. |
I don't know how the original StyleCop rule behaved, so this may or may not be by design. But even if it's by design, I'd like to challenge it to allow for a comment like this:
Currently, the rule complains that the second and third lines do not begin with "a space".
This certainly warrants discussion around exactly what the refined rule might be.
The text was updated successfully, but these errors were encountered: