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

Show security heading only if warnings exist #537

Conversation

MarkEWaite
Copy link
Contributor

Only show security heading if there is a security warning

Test highlights that there is ambiguity in the tested code because there are two booleans to represent a single condition. It is possible to have hideWarning == true and showWarning == true, even though we can only do one or the other but not both.

Another pull request or another change in this pull request will need to resolve that issue in the most recently merged pull request.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Test highlights that there is ambiguity in the tested code because there
are two booleans to represent a single condition.  It is possible to
have hideWarning == true and showWarning == true, even though we can
only do one or the other but not both.

Another pull request or another change in this pull request will need
to resolve that issue in the most recently merged pull request.
@MarkEWaite MarkEWaite added the enhancement New feature or request label Mar 3, 2023
@MarkEWaite MarkEWaite merged commit 7bdb98b into jenkinsci:master Mar 3, 2023
@MarkEWaite MarkEWaite deleted the suppress-heading-if-no-text-for-heading branch March 3, 2023 12:04
@MarkEWaite
Copy link
Contributor Author

@jiakuanghe are you interested in making the change to replace the two boolean variables that control the visibility of security warnings with a single boolean variable?

If not, I'll make that change.

I didn't consider the case where a programmer (like me writing the tests in this pull request) might make the mistake of assigning conflicting values to those two boolean variables that represent the same condition. The conflict won't be seen by users, but it will make it more difficult to change this code if two variables are used to represent the single condition. I missed that when I reviewed

@jiakuanghe
Copy link
Contributor

@jiakuanghe are you interested in making the change to replace the two boolean variables that control the visibility of security warnings with a single boolean variable?

If not, I'll make that change.

I didn't consider the case where a programmer (like me writing the tests in this pull request) might make the mistake of assigning conflicting values to those two boolean variables that represent the same condition. The conflict won't be seen by users, but it will make it more difficult to change this code if two variables are used to represent the single condition. I missed that when I reviewed

@MarkEWaite Yes, I am interested in making the change.

To keep the compatibility with the previous version, I reserved the --view-security-warnings and add --hide-security-warnings. I assumed that --view-security-warnings can be assigned to true or false by users explicitly, but actually it cannot! I am going to remove --view-security-warnings. Thanks for letting me know that!

@MarkEWaite
Copy link
Contributor Author

I assumed that --view-security-warnings can be assigned to true or false by users explicitly, but actually it cannot! I am going to remove --view-security-warnings. Thanks for letting me know that!

I don't think that we want to remove the --view-security-warnings command line argument. We don't want to break existing users if they were using the command line argument to see security warnings. Rather, the issue is purely that there are two internal variables to represent a single condition. I believe that the old internal variable needs to be deleted and the existing getter needs to read the negated value of the new variable.

@jiakuanghe
Copy link
Contributor

Rather, the issue is purely that there are two internal variables to represent a single condition.

Got it! But what if the user uses the --view-security-warnings and --hide-security-warnings at the same time as the command line argument, we should show the warnings or not?

@jiakuanghe
Copy link
Contributor

I believe that the old internal variable needs to be deleted and the existing getter needs to read the negated value of the new variable.

I agree with you. Just keeping one variable there is better. Can I remove the internal variable showWarnings directly? In this case, if the user use --view-security-warnings command line argument will not have any effects.

@MarkEWaite
Copy link
Contributor Author

Can I remove the internal variable showWarnings directly? In this case, if the user use --view-security-warnings command line argument will not have any effects.

I think so, though you'll need to check the places that are referring to that variable so that they instead refer to the hideWarnings variable instead (using a negation to invert the value of the hideWarnings variable).

@jiakuanghe
Copy link
Contributor

I think so, though you'll need to check the places that are referring to that variable so that they instead refer to the hideWarnings variable instead (using a negation to invert the value of the hideWarnings variable).

Thanks. I will do that. Do I need to create an issue and quoted it in the PR? Or it is okay to quote this #537 in my new PR?

@MarkEWaite
Copy link
Contributor Author

Thanks. I will do that. Do I need to create an issue and quoted it in the PR? Or it is okay to quote this #537 in my new PR?

Good enough to mention this in the pull request. If the mention in includes the URL of the comment, I believe GitHub will add a line in the PR history and in the comment that will show they are related to each other.

jiakuanghe pushed a commit to jiakuanghe/plugin-installation-manager-tool that referenced this pull request Mar 18, 2023
…trol the visibility of security warnings with a single boolean variable (jenkinsci#537)

- Delete the old internal variable `showWarnings` and its existing getter read the negated value of the new variable `hideWarnings`.
@jiakuanghe
Copy link
Contributor

@MarkEWaite Done #549! Please let me know if there is anything that needs to be further improved. Thanks!

@freyam
Copy link

freyam commented Mar 20, 2023

I have reviewed the PR @jiakuanghe. Great work 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants