mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
JS: Update UnusedOrUndefinedStateProperty
Using RelatedLocations to add clarity
This commit is contained in:
@@ -74,7 +74,7 @@ function l() {
|
||||
x ** 2; // $ Alert
|
||||
}
|
||||
|
||||
1n + 1; // $ MISSED: Alert
|
||||
1n + 1; // $ MISSING: Alert
|
||||
|
||||
(function(){
|
||||
let sum = 0;
|
||||
|
||||
@@ -59,7 +59,7 @@ function useThingPossiblySync(b) {
|
||||
|
||||
if (thing == null) {}
|
||||
|
||||
return thing + "bar"; // $ MISSED: Alert
|
||||
return thing + "bar"; // $ MISSING: Alert
|
||||
}
|
||||
|
||||
function useThingInVoid() {
|
||||
|
||||
@@ -6,7 +6,7 @@ function foo() {
|
||||
|
||||
function bar() {
|
||||
var g;
|
||||
g(); // $ MISSED: Alert
|
||||
g(); // $ MISSING: Alert
|
||||
eval("g = alert");
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ let c = new C();
|
||||
C(); // $ Alert
|
||||
new (x=>x); // $ Alert
|
||||
c.m();
|
||||
new c.m(); // $ MISSED: Alert
|
||||
new c.m(); // $ MISSING: Alert
|
||||
|
||||
var o = {
|
||||
f: function() {},
|
||||
@@ -21,7 +21,7 @@ var o = {
|
||||
o.f();
|
||||
new o.f();
|
||||
o.g();
|
||||
new o.g(); // $ MISSED: Alert
|
||||
new o.g(); // $ MISSING: Alert
|
||||
|
||||
function f(b) {
|
||||
var g;
|
||||
|
||||
@@ -9,10 +9,10 @@ class C1 extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends React.Component {
|
||||
class C2 extends React.Component { // $ Alert
|
||||
|
||||
state = {
|
||||
p1: ''
|
||||
p1: '' // $ RelatedLocation
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps_unmodeled(props, state) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
class C1 extends React.Component {
|
||||
class C1 extends React.Component { // $ Alert
|
||||
constructor() {
|
||||
this.state.writtenDirectly = 42;
|
||||
this.setState({
|
||||
writtenInSetState: 42
|
||||
});
|
||||
this.state.writtenInOtherMethod;
|
||||
this.state.notWritten; // $ Alert
|
||||
this.state.notWrittenButReadInChain; // $ Alert
|
||||
this.state.notWritten; // $ RelatedLocation
|
||||
this.state.notWrittenButReadInChain; // $ RelatedLocation
|
||||
this.state.writtenDirectly;
|
||||
this.state.writtenInSetState;
|
||||
|
||||
@@ -29,10 +29,10 @@ class C2 extends React.Component {
|
||||
}
|
||||
|
||||
|
||||
class C3 extends React.Component {
|
||||
class C3 extends React.Component { // $ Alert
|
||||
constructor() {
|
||||
this.state.writtenThrougExternalPropertyAccess;
|
||||
this.state.notWrittenThrougExternalPropertyAccess; // $ Alert
|
||||
this.state.notWrittenThrougExternalPropertyAccess; // $ RelatedLocation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class C1 extends React.Component {
|
||||
class C1 extends React.Component { // $ Alert
|
||||
constructor() {
|
||||
this.state.readDirectly = 42;
|
||||
this.state.readInChain = {};
|
||||
this.state.readInOtherMethod = {};
|
||||
this.state.notRead = 42; // $ Alert
|
||||
this.state.notRead = 42; // $ RelatedLocation
|
||||
this.state.readDirectly;
|
||||
this.state.readInChain.foo;
|
||||
}
|
||||
@@ -18,16 +18,16 @@ function f(s){
|
||||
}
|
||||
class C2 extends React.Component {
|
||||
constructor() {
|
||||
this.state.readWhenEscaped = 42; // $ Alert
|
||||
this.state.readWhenEscaped = 42; // $ MISSING: Alert
|
||||
f(this.state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class C3 extends React.Component {
|
||||
class C3 extends React.Component { // $ Alert
|
||||
constructor() {
|
||||
this.state.readThrougExternaPropertyAccess = 42;
|
||||
this.state.notReadThrougExternaPropertyAccess = 42; // $ Alert
|
||||
this.state.notReadThrougExternaPropertyAccess = 42; // $ RelatedLocation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user