Fix up LGTM errors
See original GitHub issueSo we’ve recently just enabled LGTM to this project and there is a number of alerts coming popping up.
We should probably try and fix most of these, barring false positives of course.
I’ve tried to group them into different types and detail my thoughts on them.
Errors
Error Type | LGTM rule | Details | Fixed? |
---|---|---|---|
Command line is built with string concatenation. | rule | Seems to be an easy fix, and a worthwhile security flaw to patch. Just need to follow details in the rules | ☑️ #3512 |
Array index out of bounds | rule | Easily fixed by adding a length check to the line if (c == '&') { just before the errors |
☑️ #3514 |
Container contents are never accessed | rule | IntelliJ seems to agree with this. I’d recommend removing and with thorough tests to ensure there are no side effects or that it isn’t accessed in an odd manner elsewhere | ☑️ #3512 |
Container contents are never initialized | rule | Again, like above I think remove and test. | ☑️ #3512 |
Inconsistent equals and hashCode | rule | I think this falls under the label of ‘over zealous checking’. As far as I can see this class is never used in such a way that hashcode is needed. Don’t think we should fix this, as it’s just not worth it | ☑️ #3518 |
Missing format argument | rule | Cervator pointed out that this one is likely a false positive. Don’t think we should ‘fix’ | ☑️ #3520 |
Type mismatch on container modification | rule | Possibly another false positive. Take a look at the code and see if it makes sense to remove it but only if it is actually causing an error | ☑️ |
Warnings
Warning Type | LGTM rule | Details | Fixed? |
---|---|---|---|
Container size compared to zero | rule | Should look at the code and test it to see if it is an issue. If it is, perhaps change to a better hasName . |
☑️ |
Dereferenced variable may be null | rule | Directly below the warning line there is a null check, so I think we should add change the conditional to something like `newItem == null | |
Implicit narrowing conversion in compound assignment | rule | There are quite a few of these. I think it’s best to go through them, if they can be fixed with a small change then do so. Otherwise I doubt it’s worth it | ☑️ |
Potential input resource leak | rule | We should probably see if we can change these to a try-with-resource style. If we can then that is a safer option. Again, on a per warning basis | ☑️ |
Result of multiplication cast to wider type | rule | Some of them are easy fixes, some are not. I think we should fix the simple ones and leave the others. Almost all of these are not capable of overflowing in the given uses of the game. | ☑️ |
Unused format argument | rule | Some, possibly all, of these are going to be false positives. Carefully evaluate each one to see what can be fixed and what doesn’t need to be | ☑️ #3520 |
Useless comparison test | rule | Similar to the first warning type. Some of these may be correct, so carefully work out if they need to be changed and an appropriate change to make. | ☑️ |
If an Error or Warning hasn’t been fixed, then please feel free to fix it. If you fix one please tick the checkbox or comment below so others know not to try and solve what has already been patched
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (12 by maintainers)
Top Results From Across the Web
Analysis FAQs - Help - LGTM
Suggested fixes. You can trigger an analysis on LGTM by pushing a new commit to the repository. If analysis fails, you should check...
Read more >About automated code review - LGTM
You can set up LGTM to run checks or builds (depending on your repository host) automatically on each pull request, so that you...
Read more >Google Code Archive - Google Code
Brad Fitzpatrick, Apr 10, 2014, b2ebbbcfc615, net/http: fix up Response. ... cmd/gc: avoid confusing error message "ovf in mpaddxx" Fixes issue 6889 LGTM=r....
Read more >LGTM - Cortex XSOAR
An Integration with LGTM API This integration was integrated and tested with version 1.0 of LGTM ... The number of alerts fixed by...
Read more >LGTM python no language data - Stack Overflow
I have no idea how to fix this and the LGTM site doesn't show any record of this error that I could find....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay cool, I think I’ll open a PR to fix some of the alerts 👍
I’ll start working on the logger errors and warnings: