SONARPY-898 Avoid failing on older SonarLint #1002
SONARPY-898 Avoid failing on older SonarLint #1002guillaume-dequenne merged 3 commits intomasterfrom
Conversation
09d0b9c to
63bd839
Compare
63bd839 to
3d5ed07
Compare
andrea-guarino-sonarsource
left a comment
There was a problem hiding this comment.
To me it's not clear what constructor will be called when PythonIndexer is present and PythonCustomRuleRepository is not.
| public PythonSensor(FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, NoSonarFilter noSonarFilter, AnalysisWarnings analysisWarnings) { | ||
| this(fileLinesContextFactory, checkFactory, noSonarFilter, null, null, analysisWarnings); | ||
| public PythonSensor(FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, | ||
| NoSonarFilter noSonarFilter, AnalysisWarningsWrapper defaultAnalysisWarningsWrapper) { |
There was a problem hiding this comment.
I think we can call the parameter analysisWarnings for consistency with other constructors
| this(fileLinesContextFactory, checkFactory, noSonarFilter, null, null, defaultAnalysisWarningsWrapper); | ||
| } | ||
|
|
||
| public PythonSensor(FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, NoSonarFilter noSonarFilter, |
There was a problem hiding this comment.
In recent version of SonarLint, my understanding is that PythonIndexer will be injected, while PythonCustomRuleRepository won't be found. So what constructor will be called in that case?
There was a problem hiding this comment.
Thanks! Indeed, due to the missing constructor, PythonIndexer ended up not being injected properly...
|
|
||
| public PythonSensor(FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, NoSonarFilter noSonarFilter, | ||
| @Nullable PythonCustomRuleRepository[] customRuleRepositories, @Nullable PythonIndexer indexer, @Nullable AnalysisWarnings analysisWarnings) { | ||
| @Nullable PythonCustomRuleRepository[] customRuleRepositories, @Nullable PythonIndexer indexer, @Nullable AnalysisWarningsWrapper analysisWarnings) { |
There was a problem hiding this comment.
I believe we can remove @Nullable annotation from analysisWarning parameter and on the corresponding field given that we always provide it.
Hence we might be able to remove the nullability check at line 117
93d46e9 to
8009276
Compare
| this.noSonarFilter = noSonarFilter; | ||
| this.indexer = indexer; | ||
| this.analysisWarnings = analysisWarnings; | ||
| LOG.info("CONSTRUCTOR CALLED: WARNING, RULE REPOSITORY AND INDEXER"); |
There was a problem hiding this comment.
I think you forgot to remove this
There was a problem hiding this comment.
Woops...Thanks! 😅
| public PythonSensor(FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, NoSonarFilter noSonarFilter, | ||
| PythonCustomRuleRepository[] customRuleRepositories, AnalysisWarnings analysisWarnings) { | ||
| this(fileLinesContextFactory, checkFactory, noSonarFilter, customRuleRepositories, null, analysisWarnings); | ||
| PythonIndexer indexer, AnalysisWarningsWrapper analysisWarnings) { |
There was a problem hiding this comment.
Let's be consistent about indentation; either we align with the parameters at the precedent line, or we uses two-space indentation everywhere (even on other constructors)
| InputFile modFile = createInputFile("mod.py"); | ||
| PythonIndexer pythonIndexer = pythonIndexer(Arrays.asList(mainFile, modFile)); | ||
| sensor(CUSTOM_RULES, pythonIndexer, null).execute(context); | ||
| sensor(null, pythonIndexer, analysisWarning).execute(context); |
There was a problem hiding this comment.
why did you change CUSTOM_RULES -> null ?
There was a problem hiding this comment.
I wanted to have a unit test with a PythonIndexer and without a PythonCustomRuleRepository to reflect the new constructor.
|
SonarQube Quality Gate |
…nnotated (#1002) Co-authored-by: Vibe Bot <[email protected]> GitOrigin-RevId: cbb9c9f4c9648b2e541e997c467235569a1f7301








No description provided.