Skip to content

Commit 7a75cff

Browse files
Merge pull request #144 from codacy/add-issue-details
feat: Update pattern documentation CF-1807
2 parents 6e09a9f + c694fc5 commit 7a75cff

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

src/views/IssueDetailsProvider.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,47 @@ export class IssueDetailsProvider {
1414
// remove h1 and h2 from explanation's markdown
1515
const curatedExplanation = pattern.explanation?.replace(/^#{1,2}\s.*\n/, '')
1616

17+
const explanationEmptyState = `At Codacy we strive to provide great descriptions for our patterns. With good explanations developers can better understand issues and even learn how to fix them.
18+
19+
For this tool we are not yet meeting this standard but you can help us improve the docs. To know more, take a look at our [tool documentation guide](https://docs.codacy.com/related-tools/tool-developer-guide/#documentation).
20+
21+
You can also visit the tool's website to find useful tips about the patterns.`
22+
23+
const rationale = pattern.rationale
24+
? `### Why is this a problem?
25+
${pattern.rationale}`
26+
: ''
27+
const solution = pattern.solution
28+
? `### How to fix it
29+
${pattern.solution}`
30+
: ''
31+
32+
const badExamples = pattern.badExamples?.length
33+
? `### Bad examples
34+
${pattern.badExamples.map((example) => `\`\`\`\n ${example}\n\`\`\``)}`
35+
: ''
36+
const goodExamples = pattern.goodExamples?.length
37+
? `### Good examples
38+
${pattern.goodExamples.map((example) => `\`\`\`\n ${example}\n\`\`\``)}`
39+
: ''
40+
41+
const examples =
42+
pattern.badExamples?.length || pattern.goodExamples?.length
43+
? `### Examples
44+
${badExamples}
45+
${goodExamples}`
46+
: ''
47+
1748
return `
1849
## ${pattern.title}
19-
${pattern.description}
50+
${rationale}
51+
52+
${solution}
53+
54+
${examples}
2055
21-
${curatedExplanation}
56+
## ${tool?.name}'s documentation
57+
${pattern.explanation ? curatedExplanation : explanationEmptyState}
2258
2359
---
2460

0 commit comments

Comments
 (0)