Commit Graph

26 Commits

Author SHA1 Message Date
Sauyon Lee
040b166eb2 Add new style build constraints and add test for the old style 2021-08-19 14:00:04 -07:00
Chris Smowton
3b927f3b6b CFG: fix lastNode relating to assignments with underscores on the LHS
For example, "x, _ := a, b" would produce an incorrect CSV that branched to the next statement after evaluating "b", skipping the assignment to 'x'. We already had test coverage for function returns, so I'm reasonably confident this only affects parallel assigns, not destructuring ones like "x, y := f()".
2020-11-03 12:00:54 +00:00
Max Schaefer
b72c4f958c Fix tests for ExprHasNoEffect on non-Linux systems. 2020-08-25 08:05:19 +01:00
Max Schaefer
57180c24c7 Simplify consistency query.
Unlike the old ODASA consistency queries, new consistency queries can have expected results, so there is no need to have special handling of files with expected errors.
2020-08-24 17:39:28 +01:00
Max Schaefer
368227fff5 Fix tests for NegativeLengthCheck. 2020-08-24 17:04:55 +01:00
Owen Mansel-Chan
97bbdca8a3 Extend negativeLengthCheck query to unsigned integers
Like return values from len and cap, unsigned integers are never negative
2020-08-11 10:48:03 +01:00
Chris Smowton
d05657ddff Make the gofmt CI test actaully fatal
Turns out gofmt doesn't actually return 1 when it finds problems, only when it finds source files which don't compile (all of which are now excluded).

This also fixes existing overlooked inconsistencies as a result of this mistake.
2020-07-10 11:02:50 +01:00
Chris Smowton
5b34c05916 UnreachableStatement: tolerate more harmless unreachable return statements
The Golang compiler isn't particularly good at spotting paths that don't need a return statement due to a dominating noreturn statement (e.g. os.Exit(1)), so dead return statements are common. We already tried to tolerate some instances of this pattern; this additionally allows 'true' and 'false' literals, and anything of type 'error'.

The carte-blanche for error values aims to accommodate the pattern "abort(); return whateverErrorWouldOtherwiseBeAppropriate();", which is probably preferable to "return nil", a misleading no-error indication.
2020-07-06 17:02:26 +01:00
Owen Mansel-Chan
23a7db5d4d Minor textual corrections 2020-05-18 17:05:49 +01:00
Owen Mansel-Chan
fbee7fe983 Add new query for redundant calls to recover 2020-05-18 16:13:46 +01:00
Max Schaefer
c15094ab9e Mark frontend errors as expected in ImposibleInterfaceNilCheck. 2020-04-17 09:51:06 +01:00
Max Schaefer
ef497afc20 Mark a frontend error in DeadStoreOfLocal tests as expected. 2020-04-17 09:51:06 +01:00
Max Schaefer
dd9738f9a6 Better fix for frontend errors in DeadStoreOfLocal tests. 2020-04-14 16:07:23 +01:00
Max Schaefer
590f146477 Fix frontend errors in DeadStoreOfLocal tests. 2020-04-14 10:51:29 +01:00
Max Schaefer
d293388172 Add failing test case for RedundantExpr. 2020-01-24 16:20:08 +00:00
Max Schaefer
fe56c207a3 Make ImpossibleInterfaceNilCheck more robust.
It no longer flags alerts that may be simply caused by missing type information.
2020-01-21 10:04:57 +00:00
Sauyon Lee
471d843025 Merge pull request #222 from max/switch-guard-nodes
Switch guard nodes
2020-01-17 21:44:59 +00:00
Max Schaefer
98c7c4a255 Autoformat. 2020-01-17 10:25:10 +00:00
Sauyon Lee
aa9489ea28 Merge pull request #218 from max/field-refs
Fix handling of references to fields and methods
2020-01-16 14:26:55 -08:00
Max Schaefer
b7a830593d Correctly create extract nodes for returns where we cannot infer the type of the returned expression, but know from context that it must be a tuple type. 2020-01-15 10:22:29 +00:00
Max Schaefer
384d21b0e9 Switch RedundantExpr query back to using AST instead of global value numbers.
Most current alerts (https://lgtm.com/rules/1510380685982/alerts/), while technically correct, are likely intentional and harmless. This change keeps only the interesting ones: https://lgtm.com/query/2999122885894714237
2020-01-10 14:46:54 +00:00
Shati Patel
e4346a17de Merge pull request #195 from max/impossible-interface-nil-check
Add new query ImpossibleInterfaceNilCheck
2019-11-27 11:15:05 +00:00
Max Schaefer
e5a12e9738 Add new query ImpossibleInterfaceNilCheck. 2019-11-26 20:28:53 +00:00
Max Schaefer
ee723d8a4f Fix DeadStoreOfField false positive.
We should look into properly desugaring embedded types in the IR, but for now this workaround should suffice.
2019-11-25 20:21:16 +00:00
Max Schaefer
06fe00006a Conservatively handle indirect updates through pointer-type receiver.
Method references `x.m` where the receiver of `m` is a pointer implicitly take the address of `x`, so they should be treated much the same as `&x` in terms of data flow. (Ideally we'd make this explicit in the data-flow graph itself, but that's for another PR.)
2019-11-12 08:54:47 +00:00
Max Schaefer
d14eb855fc Go analysis support for CodeQL. 2019-11-08 12:16:26 +00:00