sonar-delphi icon indicating copy to clipboard operation
sonar-delphi copied to clipboard

Interface for checking current compiler version in rules

Open zaneduffield opened this issue 1 year ago • 2 comments

Prerequisites

  • [X] This improvement has not already been suggested.
  • [X] This improvement would be generally useful, not specific to my code or setup.

Engine area

Rules API

Improvement description

Provide a way to check what the configured Delphi compiler version is from the perspective of a descendant of DelphiCheck. I'd imagine this would become part of the interface for DelphiCheckContext.

Rationale

Currently (as far as I can tell) there is no way for a rule to check what the configured Delphi compiler version is.

Several kinds of rules would benefit from this knowledge, including

  • rules that are suggesting use of new language features (e.g. DigitGrouping)
  • rules that are checking for bugs that only apply to a specific Delphi version (e.g. known unpatched RTL issues)

zaneduffield avatar Mar 20 '24 00:03 zaneduffield

Agreed.

Equivalent APIs in sonar-java:

  • https://github.com/SonarSource/sonar-java/blob/master/java-frontend/src/main/java/org/sonar/plugins/java/api/JavaVersionAwareVisitor.java
  • https://github.com/SonarSource/sonar-java/blob/master/java-frontend/src/main/java/org/sonar/plugins/java/api/ModuleScannerContext.java#L58

cirras avatar Mar 20 '24 00:03 cirras

It is worth noting that unlike Java projects, Delphi projects are often designed to target a wide range of versions. There might be a value loss if we threw out all issues that don't match the specified compiler version.

Could we make the configuration a bit more granular to handle these cases?

fourls avatar Apr 26 '24 02:04 fourls