-
-
Notifications
You must be signed in to change notification settings - Fork 193
3.0.2 #2524
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
3.0.2 #2524
Conversation
src = path.normalize(this.adapter.expandFileName(path.join('img',path.basename(src)))); | ||
} // img/<filename> relative to data folder | ||
if (!fs.existsSync(src)) { | ||
this.warn(`Unable to copy icon from device definition, looked at ${locations.join(', ')} and ${src}`) |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
the enclosing function
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
To fix the problem, add an explicit semicolon at the end of the this.warn(...)
statement on line 157 in lib/statescontroller.js
. This is the most direct and idiomatic way to resolve the CodeQL alert, aligning with the explicit semicolon style used throughout the function and codebase. No other changes, imports, or definitions are necessary.
-
Copy modified line R157
@@ -154,7 +154,7 @@ | ||
src = path.normalize(this.adapter.expandFileName(path.join('img',path.basename(src)))); | ||
} // img/<filename> relative to data folder | ||
if (!fs.existsSync(src)) { | ||
this.warn(`Unable to copy icon from device definition, looked at ${locations.join(', ')} and ${src}`) | ||
this.warn(`Unable to copy icon from device definition, looked at ${locations.join(', ')} and ${src}`); | ||
return; | ||
} | ||
fs.readFile(src, (err, data) => { |
}) | ||
fs.readFile(src, (err, data) => { | ||
if (err) { | ||
this.error('unable to read ' + src + ' : '+ (err && err.message? err.message:' no message given')) |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
The best way to fix this problem is to simplify the error message construction in line 162. Since the code is already inside if (err)
, we know err
is truthy, so there's no need to check err && err.message
. Instead, we can just use err.message ? err.message : ' no message given'
. In fact, it's common to write err.message || ' no message given'
in JavaScript to provide a default value.
Only line 162 needs to be changed in lib/statescontroller.js
, replacing the redundant conditional with a direct check for err.message
. No new methods, imports, or definitions are needed.
-
Copy modified line R162
@@ -159,7 +159,7 @@ | ||
} | ||
fs.readFile(src, (err, data) => { | ||
if (err) { | ||
this.error('unable to read ' + src + ' : '+ (err && err.message? err.message:' no message given')) | ||
this.error('unable to read ' + src + ' : ' + (err.message || ' no message given')) | ||
return; | ||
} | ||
if (data) { |
No description provided.