Skip to content

Conversation

@stephen-carter-at-sf
Copy link
Contributor

No description provided.

Comment on lines +45 to +53
// Force the language so that pmd doesn't look at file extensions. Note: we already associated the files based
// on their file extensions to the correct languages the typescript side.
Language pmdLanguageId = config.getLanguageRegistry().getLanguageById(language);
if (pmdLanguageId == null) {
throw new RuntimeException("The language \"" + language + "\" is not recognized by PMD.");
}
LanguageVersion forcedLangVer = config.getLanguageVersionDiscoverer()
.getDefaultLanguageVersion(pmdLanguageId);
config.setForceLanguageVersion(forcedLangVer);
Copy link
Contributor Author

@stephen-carter-at-sf stephen-carter-at-sf Dec 9, 2024

Choose a reason for hiding this comment

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

This here is the big win. We now can ignore pmd's default association from file extension to language and just force the language ourselves on a given set of files.

So now we can associate on the typescript side the file_extensions that are associated with a specific pmd language to accomodate for the PMD AppExchange Rules, etc.

@stephen-carter-at-sf stephen-carter-at-sf force-pushed the sc/pmdAppExchange branch 2 times, most recently from e7bf56e to 70ba652 Compare December 9, 2024 23:30
@@ -0,0 +1,130 @@
package com.salesforce.sfca.pmdwrapper;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was actually just renamed from PmdRuleRunner... not sure why github thought this was a delete and an add. Sorry for the noise.

@@ -0,0 +1,37 @@
package com.salesforce.sfca.shared;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing new in this shared folder... just moved stuff. Again sorry for the noise.

}

@Test
void whenCallingRunWithZeroLanguages_thenError(@TempDir Path tempDir) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Could the test name explain what it means to have zero languages, the way whenCallingRunWithEmptyArrayFor_filesToScan_thenError does? Maybe whencallingRunWithEmptyObjectFor_runDataPerLanguage_thenError? Or is that too wordy to be helpful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Fixed.

@stephen-carter-at-sf stephen-carter-at-sf merged commit 54f6986 into dev Dec 10, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants