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

Create rule S7119: Global should not depend on possibly not yet initialized variables CPP-5655 #4387

Merged
merged 28 commits into from
Nov 7, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 8, 2024

You can preview this rule here (updated a few minutes after each push).

Review

A dedicated reviewer checked the rule description successfully for:

  • logical errors and incorrect information
  • information gaps and missing content
  • text style and tone
  • PR summary and labels follow the guidelines

@github-actions github-actions bot added the cfamily C / C++ / Objective-C label Oct 8, 2024
@tomasz-kaminski-sonarsource tomasz-kaminski-sonarsource changed the title Create rule S7119 CPP-5655 Create rule S7119 Oct 8, 2024
@tomasz-kaminski-sonarsource tomasz-kaminski-sonarsource changed the title CPP-5655 Create rule S7119 CPP-5655 Create rule S7119: Global and static variables should not dependent on possibly uninitialized global variables Oct 8, 2024
@tomasz-kaminski-sonarsource tomasz-kaminski-sonarsource changed the title CPP-5655 Create rule S7119: Global and static variables should not dependent on possibly uninitialized global variables CPP-5655 Create rule S7119: Global and static variables should not dependent on possibly not yet initialized variables Oct 8, 2024
@loic-joly-sonarsource loic-joly-sonarsource changed the title CPP-5655 Create rule S7119: Global and static variables should not dependent on possibly not yet initialized variables Create rule S7119: Global and static variables should not dependent on possibly not yet initialized variables CPP-5655 Oct 9, 2024
Copy link
Contributor

@loic-joly-sonarsource loic-joly-sonarsource left a comment

Choose a reason for hiding this comment

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

In the past, I used the Nifty counter idiom to solve initialization order issues. I'm not sure how relevant it is today, but it might be useful for legacy code? Should it be mentioned?

rules/S7119/cfamily/metadata.json Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
@tomasz-kaminski-sonarsource
Copy link
Contributor

In the past, I used the Nifty counter idiom to solve initialization order issues. I'm not sure how relevant it is today, but it might be useful for legacy code? Should it be mentioned?

I think just having a function that returns a reference is a better and simpler solution in that case; see llvm::errs() vs std::cout. If you know good article about the Nifty counter, I think we could link it.

@tomasz-kaminski-sonarsource tomasz-kaminski-sonarsource changed the title Create rule S7119: Global and static variables should not dependent on possibly not yet initialized variables CPP-5655 Create rule S7119: Global should not depend on possibly not yet initialized variables CPP-5655 Oct 10, 2024
=== Articles & blog posts

* Stack Overflow - Answer by Gabriel Staples for https://stackoverflow.com/a/73027793/24103368[What is the point of declaring "const volatile int *p"?]
* Stack Overflow - Answer by Gabriel les for https://stackoverflow.com/a/73027793/24103368[What is the point of declaring "const volatile int *p"?]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change that?

Choose a reason for hiding this comment

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

By pure accident, I will fix that. Thank you for caching it.

Choose a reason for hiding this comment

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

Fixed

rules/S7119/cfamily/metadata.json Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
Copy link
Contributor

@loic-joly-sonarsource loic-joly-sonarsource left a comment

Choose a reason for hiding this comment

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

Approved after a few typos are fixed

rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
rules/S7119/cfamily/rule.adoc Outdated Show resolved Hide resolved
Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@frederic-tingaud-sonarsource frederic-tingaud-sonarsource marked this pull request as ready for review November 7, 2024 16:46
Copy link

sonarqube-next bot commented Nov 7, 2024

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Copy link

sonarqube-next bot commented Nov 7, 2024

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@frederic-tingaud-sonarsource frederic-tingaud-sonarsource merged commit ee3e232 into master Nov 7, 2024
8 of 10 checks passed
@frederic-tingaud-sonarsource frederic-tingaud-sonarsource deleted the rule/add-RSPEC-S7119 branch November 7, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cfamily C / C++ / Objective-C
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants