Skip to content

Commit 0a8bab7

Browse files
FIX(pmd): @W-17321151@: Rule description should not provide undefined resourceUrls
1 parent 10bfb8b commit 0a8bab7

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/code-analyzer-pmd-engine/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@salesforce/code-analyzer-pmd-engine",
33
"description": "Plugin package that adds 'pmd' and 'cpd' as engines into Salesforce Code Analyzer",
4-
"version": "0.14.0",
4+
"version": "0.14.1-SNAPSHOT",
55
"author": "The Salesforce Code Analyzer Team",
66
"license": "BSD-3-Clause",
77
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",

packages/code-analyzer-pmd-engine/src/pmd-engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function toRuleDescription(pmdRuleInfo: PmdRuleInfo): RuleDescription {
118118
severityLevel: toSeverityLevel(pmdRuleInfo.priority),
119119
tags: ['Recommended', pmdRuleInfo.ruleSet.replaceAll(' ', ''), languageId + 'Language'],
120120
description: pmdRuleInfo.description,
121-
resourceUrls: [pmdRuleInfo.externalInfoUrl] // TODO: Eventually we'll want to add in well architected links
121+
resourceUrls: pmdRuleInfo.externalInfoUrl ? [pmdRuleInfo.externalInfoUrl] : [] // TODO: Eventually we'll want to add in well architected links
122122
};
123123
}
124124

packages/code-analyzer-pmd-engine/test/pmd-engine.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('Tests for the describeRules method of PmdEngine', () => {
152152
const fakeRule10Description: RuleDescription = expectContainsRuleWithName(ruleDescriptions, 'fakerule10'); // From somecat4.xml
153153
expect(fakeRule10Description.severityLevel).toEqual(SeverityLevel.High);
154154
expect(fakeRule10Description.tags).toEqual(['Recommended', 'SomeCat4', 'javascriptLanguage']);
155+
expect(fakeRule10Description.resourceUrls).toHaveLength(0); // This particular rule purposely has no externalInfoUrl defined, so we confirm that it gives no resourceUrls.
155156
expectContainsRuleWithName(ruleDescriptions, 'fakerule11'); // From somecat4.xml
156157
expectContainsRuleWithName(ruleDescriptions, 'fakerule12'); // From somecat4.xml
157158
expectContainsRuleWithName(ruleDescriptions, 'fakerule13'); // From somecat4.xml

packages/code-analyzer-pmd-engine/test/test-data/custom rules/subfolder/somecat4.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
message="Avoid using with - it's bad news"
1616
language="ecmascript"
1717
since="5.0.1"
18-
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
19-
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_bestpractices.html#avoidwithstatement">
18+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"> <!-- Removed the externalInfoUrl attribute so that we can test what happens when this is missing -->
2019
<description>Avoid using with - it's bad news</description>
2120
<priority>1</priority>
2221
<properties>

0 commit comments

Comments
 (0)