-
Notifications
You must be signed in to change notification settings - Fork 41
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
Producing Linter Hit List #35
Comments
Sounds great! I also think it’s possible to improve the error messages generally since they can be kind of hard to grasp. Maybe I can start with a boilerplate and you can help me make things clearer if it’s hard to understand? |
Perhaps the list of messages. I'll work on the infra since I already got some in hand. How would you prefer the code submission?
|
Cool, thanks! Just fork this and create a PR to master whenever you feel ready! |
Bump. Would you mind create an organization named Source: https://pages.github.com/ |
Never mind. I managed to workaround it. The final URL should be something like: |
Great that you worked it out! I think it's a bit too soon/too serious to create an organisation and all that already. I can think of three ways to document this:
I don't think there's a good idea to overdo it right now and I the go-critic example you linked would be fairly easy to reproduce with regular markdown in the README to replace all the code blocks in there now. |
I actually managed to integrate the engine into the repository. Currently testing out at: https://hollowaykeanho.github.io/wsl/en-us/. The write up is markdown so it's easy for you. =) Let me know your thought. But heads up: I'm so bad at designing. Will help to scout out better design templates. EDIT:
|
All right.. Styling completed. Please review the test site and play with it. If you're all good, I'm ready to create the merge request. |
Oh, wow. Thank your for your effort! Although it's a bit much all at once going on here and I'm not sure that's exactly what I had in mind. I think a good start might be to just add the markdown to the repository just like go-critic does with their overview. I really appreciate the work you've put in to this but it feels a bit premature and since there's not really a proper documentation without the sidebar, linking, examples etcetera maybe it's a good idea to start there. When we feel like the documentation and understanding of the linter is sufficient it might be a good idea to improve the documentation. I also see that you introduced some kind of short name for the errors. I think this might be a good idea but before we do that it's important to define all the different error to ensure we have a logical system. If we alter the error messages we have to keep in mind that a change like that should probably result in a new major release. I don't think it's a good idea to introduce multiple languages this early. It will add a hard dependency and I won't be able to do changes requiring the documentation to be updated. For now I think english is good enough and if someone is having a hard time understand maybe a link to Google Translate will be just as good. I thin the concept of a logo is quite unnecessary and even though I see you have added a disclaimer I would prefer to just skip it completely, mainly since it's yet another think to maintain and handle. When the time is right I'm open to the idea of a gopher in the readme but I think that's sufficient. So again, I really appreciate you spending time with this but I'm not ready to introduce this kind of worrk and merge it to
|
Actually you have a point, I didn't set the priority correctly. Don't worry about it. The tech was pre-made there actually. It's just a few cmd instruction and you can get it back. 😄
In that case, shall I create EDIT: Changes:
|
@hollowaykeanho Thanks, this is a great start! I think doc is fine (or docs according to standard package layout). Feel free to chose whichever (the project itself isn't currently following that layout). Also if you want to you may remove the documentation from the README when an equivalent description is moved to the checklist. |
Great! I'll proceed accordingly. =)
For time being I try not to touch |
Question: is the single-line block return statement correct? I'm getting a bunch of Edit: Specifically looking at |
Not sure if I follow but the changes
So you only have to consider code that's already formatted. The Sign example would be: func Sign(y int) string {
if y+2 > 0 {
y = 0
}
return fmt.Sprintf("Hello world by %v\n", y)
} The shorter version that's allowed is something like this: func (t *Typ) SetX(x int) *Typ {
t.X = x
return t
} |
Looks like I caught the wrong message. Amended. |
Quick question: how to get hit by branch statements should not be cuddled if block has more than two lines? https://github.com/hollowaykeanho/wsl/blob/master/wsl.go#L341 Update: I'm currently reading through source codes to find uncommon hits. |
They should all be in the README although without the name. Branch is for k, v := range aMap {
fmt.Println(k)
fmt.Println(v)
break
} Although there are probably better and more realistic usage of |
All done! Please review: https://github.com/hollowaykeanho/wsl/blob/master/doc/rules.md Things like:
I had tested the examples on my side. Should be fine. Most of them are from my packages refactoring using the latest If you spot something, please write it out here. I will |
@hollowaykeanho Sorry for a bit of a slow reply! I think this is a great start and I'm happy to merge it as is and do some kind of re-work from there. A few things I think at first glance:
But all and all I think this is great and it's easy to search for the error message reported from the linter and find a way to resolve it. If you create a PR with the current state I'll happily merge it and continue the work with the minor fixes myself! Thank you so much for your interest and help documenting this linter! 🎉 |
I tried it locally. This is the package main
import (
"fmt"
)
func example(eolType int) string {
var (
eol = ""
i = 0
)
if eolType < 0 {
return ""
}
i = eolType
switch i {
case 2:
eol = "\r"
case 3:
eol = "\r\n"
case 1:
fallthrough
default:
eol = "\n"
}
return eol
}
func main() {
fmt.Printf("%v\n", example(2))
}
Applied.
Applied.
Done. That's the seal I was referring to. Pull request achieved. Glad this is done. XD |
* doc: added rules.md to write checks rules The existing rules are described as an overview inside README.md. The team needs a dedicated Markdown page to consolidate all the check hits details and examples. This would help customers to easily identify the hits and apply the amendment. As described by Simon Sawert, current project phase focuses on debugging and further develop wsl linter's program itself. Hence, the documentations can change abruptly so we should keep it as simple as a single Markdown file for now. This patch adds the rules.md into `doc` directory. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: applied Github formatting rendering Github has a specialized requirements when it comes to Markdown rendering. The existing doc/rules.md is not written in a compliant manner. This patch applies Github Markdown rendering into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * README.md: added a checklist section for each hits The existing README.md is not linked to doc/rules.md. Hence, we need to link them. This patch adds a checklist section into README.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: add "expressions should not be cuddled with blocks" Another rule detected but not documented in doc/rules.md is the "expressions should not be cuddled with blocks". We need to document it. This patch adds "expressions should not be cuddled with blocks" into the `doc/rules.md`. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: add return statements should not be cuddled... rule wsl has a return rule where "return statements should not be cuddled if block has more than two lines" and it is not documented. Hence, we need to document it under the rules.md documentation. This patch adds "return statements should not be cuddled if block has more than two lines" into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added "go statements can only invoke func..." rule wsl reported an undocumented rule: "go statements can only invoke functions assigned on line above". Hence, we need to document it inside the rules book. This patch adds the missing rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "only one cuddle ... go statement" An undocumented rule appeared: "only one cuddle assignment allowed before go statement" Hence, we need to document it. This patch adds the above rule into `doc/rules.md`. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: style separators for better reading via scrolling The existing separator is not clear on the documentations. Hence, we need to amend it to match Github rendering styles. This patch restyled the separator between rules. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added "for statement without condition..." rule wsl detected a new rule: "for statement without condition should never be cuddled" It was undocumented in the rules book. Hence, we need to document it for clarity purposes. This patch adds the specified rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added "if statements should only be cuddled..." rule wsl linter detected a new rule: "if statements should only be cuddled with assignments" It is undocumented in the rules book. Hence, we need to document it as soon as possible. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added "assignments should only be cuddled..." rule Another undocumented rule detected: "assignments should only be cuddled with other assignments" Hence, we need to document it. This patch adds the mentioned rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "block should not start with a whitespace" Another undocumented rule: "block should not start with a whitespace" Hence, we need to document it. This patch adds the above undocumented rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "block should ... whitespace (or comment)" Another undocumented rule: "block should not end with a whitespace (or comment)" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "if statements should ... if statement itself" Another undocumented rule detected: "if statements should only be cuddled with assignments used in the if statement itself" Hence, we need to document it. This patch add the above undocumented rule into `doc/rules.md`. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "anonymous switch statements ... cuddled" Another undocumented rule: "anonymous switch statements should never be cuddled" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "append only allowed ... appended value" Another undocumented rule was detected: "append only allowed to cuddle with appended value" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "only one cuddle assignment...range..." An undocumented rule detected: "only one cuddle assignment allowed before range statement" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "ranges should only ... assignments" Another undocumented rule detected: "ranges should only be cuddled with assignments" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule ""switch statements should ... switched" An undocumented rule appeared: "switch statements should only be cuddled with variables switched" Hence, we should document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "declarations should never be cuddled" An undocumented rule appeared: "declarations should never be cuddled" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "stmt type not implemented" An undocumented rule detected: "stmt type not implemented" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "only cuddled expressions if ... line above" an undocumented rule appeared: "only cuddled expressions if assigning variable or using from line above" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "only one cuddle assignment...for" an undocumented rule appeared: "only one cuddle assignment allowed before for statement" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "branch statements should ... two lines" An undocumented rule appeared: "branch statements should not be cuddled if block has more than two lines" Hence, we should document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "expressions should not be cuddled...var" An undocumented rule appeared: "expressions should not be cuddled with declarations or returns" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "only one cuddle ... defer statement" An undocumented rule appeared: "only one cuddle assignment allowed before defer statement" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "defer statements should ... same variable" An undocumented rule appeared: "defer statements should only be cuddled with expressions on same variable" Hence, we need to document it. This patch adds the above rlue into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "for statements should ... iteration" An undocumented rule appeared: "for statements should only be cuddled with assignments used in the iteration" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "type switch statements ... switched" An undocumented rule appeared: "type switch statements should only be cuddled with variables switched" Hence, we need to document it. This patch adds the rule above into doc/rules.md Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * doc/rules.md: added rule "only one ... type switch statement" An undocumented rule appeared: "only one cuddle assignment allowed before type switch statement" Hence, we need to document it. This patch adds the above rule into doc/rules.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * README.md: removed duplicated rule section Now that the individual hit list is available, the rule section is no longer available. Also, those list are currently checked against hollowaykeanho repository. They should be changed to bombsimon instead after the pull request. This patch updates the README.md rules and checklist section by removing the existing rules and updating the final URL path. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * README.md: separate the installation guide from usage The current instructions for usage and installations are fused together. This is not preferrable. Hence, we should split them for removing the confusion. This patch separates the installation guide from the usage guide in README.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com> * README.md: reworded usage guide The current usage guide is oversimplified. Hence, we need to reword it to makes more sense, supporting both local installation and CI automation. This patch rewords usage guide in README.md. Signed-off-by: (Holloway) Chew, Kean Ho <kean.ho.chew@zoralab.com>
Closing this issue now that the list is in place! Enhancements will be handled outside of this issue. Again, thank you for your help and time! |
Can we produce a "hit" list for explaining each hits and how to amend them? E.g. https://go-critic.github.io/overview
I do not mind contribute back. I see a lot of good potential for this linter. =)
EDIT: added mind
The text was updated successfully, but these errors were encountered: