-
Notifications
You must be signed in to change notification settings - Fork 44
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
refactor: Cleanup Linter Complaints and Setup Makefile #63
Conversation
Some todo's needed to temporarily bybass some linter errors.
conflicts (so that auto-merge doesn't mess things up).
Merge branch 'develop' into lone/feature/linters-and-nice-to-haves Tests still failing, still investigating.
Handle collection name from @collection directivedefradb/query/graphql/schema/generate.go Lines 676 to 681 in be4c24b
This comment was generated by todo based on a
|
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 to me - thanks for the cleanup :) Just have a couple of minor comments on specific lines, plus the below:
- I would much prefer the deletion of unused code instead of commenting it out, in most cases you seem to be making the problem worse in a sense by adding an an extra line of eye-space describing that it is commented out because it is unused.
- Having to declare new names for every error variable within a scope doesn't seem ideal, and feels like a waste of mental energy when writing, and needless code clutter when reading - however this feels like it is potentially useful due to a Go 'quirk' allowing multiple variables with the same name (instead of the usual overwrite the existing variable in most langs I've worked with). Is this ever a problem with errors and we want to enforce the lint-rule, or is it safe to disable this one? (or is the lint rule getting me confused and Go behaves like a normal lang here, and the lint is about mutation or something?)
Thanks for the review @AndrewSisley, responding to your comment here.
I am on the same same page about deletion of unused code instead of commenting it out, I did that for now as It is a big batch of removal for lots of unused code spanning many files and there could perhaps be some important unused code that we may want for reference (sometimes it's easier to have some code as comments rather than to look at past git history). Will be nice if @jsimnz can point out code that I commented out that he would like to keep for reference, this way before the PR gets merged I can delete that code. Another reason I was hesitant to delete code straight away was if there was any partial implementation that was being worked on and somehow got merged into develop (which we should absolutely avoid in the future). The extra line of describing why the comment was there is only for the draft PR review to help understand why a comment was made, rest assured those can also be removed before the merge.
Absolutely, I found that this was only an issue for 2 of the linters which now may have been disabled, it was referring to |
Ahh I wouldnt worry about partial implementations here - you are deleting full declarations, not parts of function so the compiler will flag anything pretty safely I think. But fair enough :) I can be quite heavy-handed with this kind of stuff lol Nice - thanks for that effort plus info (re error stuff) :) |
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.
just a few changes.... :D
2) Resolve new linter errors from the merge with parents. 3) Resolved the conflicts from: Merge branch 'develop' into lone/feature/linters-and-nice-to-haves
paramaterize ns/suffixLines 39 to 42 in 8ccafae
This comment was generated by todo based on a
|
Expand delta metadata (investigate if needed)Lines 37 to 40 in 8ccafae
This comment was generated by todo based on a
|
check if NonNull is possible heredefradb/query/graphql/schema/generate.go Lines 195 to 198 in 8ccafae
This comment was generated by todo based on a
|
are surpressed are the ones that are unused code / dead-code.
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.
lgtm
) * Linter and Makefile setup. * Change go-cross-build.sh script to be executable. * All default linters errors resolved. Some todo's needed to temporarily bybass some linter errors. * Comment line-wise instead of block-wise, to ensure that we can get merge conflicts (so that auto-merge doesn't mess things up). * Fix the txn.go bug * Clean up all other @todo linter errors. Now the only linter errors that are surpressed are the ones that are unused code / dead-code.
DESCRIPTION:
This PR sets up a Makefile workflow and resolves the cries from these following Go Linters (around 150 linter errors):
- deadcode
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
ISSUE:
Started from #42 but added alot more goodies.
BEFORE-MERGE:
Since a lot of dead code had to be edited out, I predict lots of breakage if new features are merged that make use of any of that code that was commented (without syncing with this branch). So really ensure even after there are no conflicts that nothing broke.
Needs a very thorough review to ensure I haven't done any BAD GO THINGS while resolving these linter errors.
Would prefer like @AndrewSisley suggested to also delete as much code as possible rather than having comments before the merge.
TODO:
There are tons more linters we can now very easily add with our configuration file (.golangci.sourceinc.yaml). Some good ones that I think we can add soon are:
NOTES:
There are some
nolint:<linter-to-ignore>
style placed to suppress the linter that we should eventually address. These can also be quickly found if you runmake lint:todo
command (and haveripgrep
installed).