longhorn-manager icon indicating copy to clipboard operation
longhorn-manager copied to clipboard

[CI]: static analysis checks

Open m-ildefons opened this issue 1 year ago • 4 comments
trafficstars

  • Introduce static analysis into the validation step of the build process, using the tool staticcheck

  • Fix problem areas found by staticcheck. Most of the fixes are dead code removals and style issues, but there are also some potential nil dereferences and code duplication issues. The fixes are broken up into many small commits making it easier to review and validate them.

Related to: https://github.com/longhorn/longhorn/issues/7300

m-ildefons avatar Dec 22 '23 14:12 m-ildefons

This pull request is now in conflicts. Could you fix it @m-ildefons? 🙏

mergify[bot] avatar Dec 23 '23 10:12 mergify[bot]

@PhanLe1010 the documentation you quoted is talking about how the command line interface is similar to go vet or go build.

go build is executing the actual compiler on the source file which is different that executing a linter. The compiler may accept inputs simply because they are legal within the language spec - even though there is a high likelyhood that they are buggy. A static analysis tool, like go vet or staticcheck is meant to catch such problems and alert on them. However different static analysis tools may alert on different problems. go vet for example specializes in checking the usage of standard library functions like the sync or atomic libraries or the sanity of printf arguments. staticcheck is the successor of go lint which was in use by Longhorn previously, but it's no longer maintained, but staticcheck also looks for quite a few more errors than go lint did, most notably unused code, scope of variables and about 150 other potential problems.

I hope this answers your question.

m-ildefons avatar Jan 02 '24 10:01 m-ildefons

Also for context referencing, please add the issue number in the commit message. Thank you.

@m-ildefons will you be including the issue numbers in each commit message? I suggest not using longhorn/longhorn#7300 since it might flood the issue with commit notification messages.

c3y1huang avatar Jan 04 '24 06:01 c3y1huang

This pull request is now in conflict. Could you fix it @m-ildefons? 🙏

mergify[bot] avatar Feb 07 '24 14:02 mergify[bot]

@m-ildefons Just reviewed the changes. The commits remove the dead codes, check the unhandled variables, and fix incorrect formatting errors. Good job! Can you help resolve the conflicts and address @c3y1huang's comment before merging the PR? Thank you.

derekbit avatar Apr 10 '24 03:04 derekbit

This pull request is now in conflict. Could you fix it @m-ildefons? 🙏

mergify[bot] avatar Apr 24 '24 16:04 mergify[bot]

@FrankYang0529 Can you help review this PR and see if we can close the PR? I think most of the fixes have been included in your golint fix PR.

cc @innobead

derekbit avatar Apr 28 '24 12:04 derekbit

The PR has been pending for a long time and without update. Most of the warnings and errors are fixed by @FrankYang0529. Let's close it.

cc @innobead

derekbit avatar Jun 25 '24 16:06 derekbit