Skip to content
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

GHA CI: add CodeQL scanning #18687

Merged
merged 3 commits into from
Mar 15, 2023
Merged

GHA CI: add CodeQL scanning #18687

merged 3 commits into from
Mar 15, 2023

Conversation

Chocobo1
Copy link
Member

@Chocobo1 Chocobo1 commented Mar 11, 2023

@Chocobo1 Chocobo1 added the CI Issues/PRs related to CI label Mar 11, 2023
@Chocobo1 Chocobo1 changed the title Codeql GHA CI: add CodeQL scanning Mar 11, 2023

query-filters:
- exclude:
id: js/superfluous-trailing-arguments
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has too many false-positives at the moment so exclude it for now.

Copy link
Member

@glassez glassez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there are many warnings that look like false positives. What do you suggest to do with them?

@@ -68,8 +68,9 @@
}

// Register keyboard events to modal window
var keyboard = undefined;
if (!keyboard) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to check it if you assigned it to undefined just above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it to var keyboard; but I wanted to be explicit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL report the variable wasn't declared before use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL report the variable wasn't declared before use.

Although I am not familiar enough with JS stuff, but to me it looked as if keyboard was intended to preserve a previously assigned value (i.e., to reuse Keyboard object once created).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise it is meaningless to check variable just declared as undefined, isn't it?

Copy link
Member

@glassez glassez Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the variable is still declared in the scope in which it is used.

This is the confusing point which my previous comment aims to address.

It still looks to me like an attempt to give a slightly less confusing look to something that is confusing by nature. But I won't go into further discussions about it. It is enough that now (after applying var keyboard;) the "fixing the analyzer warnings" does not break the logic of the program.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the confusing point which my #18687 (comment) aims to address.

commit updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still looks to me like an attempt to give a slightly less confusing look to something that is confusing by nature.

Yes and in the future with the analyzer in place, new code can be inspected better or even rewritten to avoid such situations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's pretty confusing. i believe @glassez is correct in that you can redeclare var keyboard

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very, very bad and confusing practice. It is better to avoid legacy JS mistakes and do something like

let { keyboard } = globalThis;
if (!keyboard) {
    keyboard = new Keyboard({

src/webui/www/private/scripts/piecesbar.js Show resolved Hide resolved
src/webui/www/private/views/log.html Outdated Show resolved Hide resolved
@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 12, 2023

What do you suggest to do with them?

Why don't you just state your intend? I would suppress the warnings with the most false positives and keep the lesser ones. The remaining false positives can be dismissed by hand.

@Chocobo1
Copy link
Member Author

I would suppress the warnings with the most false positives and keep the lesser ones. The remaining false positives can be dismissed by hand.

After suppressing some CodeQL checks, the final report looks clean now.

@glassez
Copy link
Member

glassez commented Mar 12, 2023

What do you suggest to do with them?

Why don't you just state your intend?

I didn't have clear intentions, I just saw a picture that I didn't like. Using analyzers that give a lot of false positives can have a negative effect. I suppose you've at least got a little familiar with CodeQL, since you're offering it. So I would expect it to be configured as much as possible before we merge it (assuming it can be configured appropriately).

@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 12, 2023

What do you suggest to do with them?

Why don't you just state your intend?

Using analyzers that give a lot of false positives can have a negative effect. I suppose you've at least got a little familiar with CodeQL, since you're offering it. So I would expect it to be configured as much as possible before we merge it (assuming it can be configured appropriately).

Of course and I meant you could just say that (wished for less false positives) instead of asking my opinion which I find it to be ambiguous.

Also IMO the CodeQL is more useful for the js language than for c++ since there wasn't any good static analyzer employed. As for c++ just think of it as another checker for reference, it might be occasionally useful and it won't (shouldn't) be a hard block for merging PRs.

@xavier2k6

This comment was marked as off-topic.

@Chocobo1

This comment was marked as off-topic.

@Chocobo1 Chocobo1 merged commit f16e903 into qbittorrent:master Mar 15, 2023
@Chocobo1 Chocobo1 deleted the codeql branch March 15, 2023 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Issues/PRs related to CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants