Skip to content

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

Merged
merged 4 commits into from
Jul 18, 2025
Merged

3.0.2 #2524

merged 4 commits into from
Jul 18, 2025

Conversation

asgothian
Copy link
Collaborator

No description provided.

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

Avoid automated semicolon insertion (92% of all statements in
the enclosing function
have an explicit semicolon).

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.


Suggested changeset 1
lib/statescontroller.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/statescontroller.js b/lib/statescontroller.js
--- a/lib/statescontroller.js
+++ b/lib/statescontroller.js
@@ -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) => {
EOF
@@ -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) => {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
})
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

This use of variable 'err' always evaluates to true.

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.


Suggested changeset 1
lib/statescontroller.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/statescontroller.js b/lib/statescontroller.js
--- a/lib/statescontroller.js
+++ b/lib/statescontroller.js
@@ -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) {
EOF
@@ -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) {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@asgothian asgothian merged commit 9d97a02 into ZHC_latest Jul 18, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants