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

Handle deprecated rules in ClangTidy LLVM 19.1 #2824

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

guwirth
Copy link
Collaborator

@guwirth guwirth commented Nov 26, 2024


This change is Reviewable

- addDeprecatedRuleKey

deprecated rules:

- C++14
  - clang-diagnostic-c++1y-extensions -> clang-diagnostic-c++14-extensions
- C++17
  - clang-diagnostic-c++1z-compat -> clang-diagnostic-c++17-compat
  - clang-diagnostic-c++1z-compat-mangling -> clang-diagnostic-c++17-compat-mangling
  - clang-diagnostic-c++1z-extensions -> clang-diagnostic-c++17-extensions
- C++20
  - clang-diagnostic-c++2a-compat -> clang-diagnostic-c++20-compat
  - clang-diagnostic-c++2a-compat-pedantic -> clang-diagnostic-c++20-compat-pedantic
  - clang-diagnostic-c++2a-extensions -> clang-diagnostic-c++20-extensions
- C++23
  - clang-diagnostic-c++2b-extensions -> clang-diagnostic-c++23-extensions
  - clang-diagnostic-pre-c++2b-compat -> clang-diagnostic-pre-c++23-compat
  - clang-diagnostic-pre-c++2b-compat-pedantic -> clang-diagnostic-pre-c++23-compat-pedantic
- C++26
  - clang-diagnostic-c++2c-compat -> clang-diagnostic-c++26-compat
  - clang-diagnostic-c++2c-extensions -> clang-diagnostic-c++26-extensions
  - clang-diagnostic-pre-c++2c-compat -> clang-diagnostic-pre-c++26-compat
  - clang-diagnostic-pre-c++2c-compat-pedantic -> clang-diagnostic-pre-c++26-compat-pedantic
@guwirth guwirth added this to the 2.2.0 milestone Nov 26, 2024
@guwirth guwirth self-assigned this Nov 26, 2024
@guwirth
Copy link
Collaborator Author

guwirth commented Nov 26, 2024

First try calling addDeprecatedRuleKey, starting the server I get:

  • Caused by: java.lang.IllegalStateException: The following rule keys are declared both as deprecated and used key [clangtidy:clang-diagnostic-c++1y-extensions,clangtidy:clang-diagnostic-c++2c-extensions,clangtidy:clang-diagnostic-pre-c++2c-compat-pedantic,clangtidy:clang-diagnostic-pre-c++2c-compat,clangtidy:clang-diagnostic-c++1z-compat-mangling,clangtidy:clang-diagnostic-c++2a-compat,clangtidy:clang-diagnostic-c++1z-compat,clangtidy:clang-diagnostic-pre-c++2b-compat,clangtidy:clang-diagnostic-c++2b-extensions,clangtidy:clang-diagnostic-c++2a-extensions,clangtidy:clang-diagnostic-c++2a-compat-pedantic,clangtidy:clang-diagnostic-c++1z-extensions,clangtidy:clang-diagnostic-pre-c++2b-compat-pedantic]

@guwirth
Copy link
Collaborator Author

guwirth commented Nov 26, 2024

Mark rules with status=DEPRECATED in repository, still the message during server start

java.lang.IllegalStateException: The following rule keys are declared both as deprecated and used key [clangtidy:clang-diagnostic-c++1y-extensions,clangtidy:clang-diagnostic-c++2c-extensions,clangtidy:clang-diagnostic-pre-c++2c-compat-pedantic,clangtidy:clang-diagnostic-pre-c++2c-compat,clangtidy:clang-diagnostic-c++2a-compat,clangtidy:clang-diagnostic-c++1z-compat,clangtidy:clang-diagnostic-c++0x-extensions,clangtidy:clang-diagnostic-pre-c++2b-compat,clangtidy:clang-diagnostic-c++2b-extensions,clangtidy:clang-diagnostic-c++2a-extensions,clangtidy:clang-diagnostic-c++1z-extensions,clangtidy:clang-diagnostic-pre-c++2b-compat-pedantic,clangtidy:clang-diagnostic-c++0x-compat]

@guwirth
Copy link
Collaborator Author

guwirth commented Nov 27, 2024

Summary:

  1. Rule status: status does not affect the operation of a rule and has no impact on its issues, essentially only the status is displayed in the Web UI. There are three possible rule statuses: beta, ready, and deprecated. Sometimes, rules are first issued in beta status and then moved to ready. Most rules are in ready status; ready to be used in production. When Sonar developers realize that a rule no longer makes sense, they first deprecate the rule, then eventually drop it.

Hint: Recommendation is to mark a rule first deprecated and remove/replace it in a later version then.

  1. addDeprecatedRuleKey: If you want to rename the key of a rule or change its repository or both, register the rule's previous repository and key This will allow SonarQube to support "issue re-keying" for this rule. If the repository and/or key of an existing rule is changed without declaring deprecated keys, existing issues for this rule, created under the rule's previous repository and/or key, will be closed and new ones will be created under the issue's new repository and/or key.

Hint: Rules marked deprecated with addDeprecatedRuleKey must no longer be in the repository, not even with the status deprecated. If this hint is ignored, the server start is aborted and the error message java.lang.IllegalStateException: The following rule keys are declared both as deprecated and used key ... is written to the LOG file.

  1. If a sensor should support the old and new rule in a report during the analysis, the plugin must implement this itself.
  • Mark rules as deprecated in the repository and no mapping in the sensor. Old rules/issues are displayed as deprecated.
  • Remove deprecated rules in the repository and thus discard associated issues
  • Remove deprecated rules in the repository and map to new rules in the plugin/sensor. Issues are all displayed under the new key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

clang: Handle old C++ standard aliases
1 participant