Skip to content

Commit fe4db32

Browse files
authored
Merge pull request #185 from codacy/disable-pattern-CF-2151
Disable pattern CF-2151
2 parents 1623db9 + f1a9a54 commit fe4db32

11 files changed

Lines changed: 680 additions & 18 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//@ts-check
2+
/// <reference lib="dom" />
3+
4+
/* global acquireVsCodeApi, document */
5+
6+
/**
7+
* @typedef {Object} VsCodeApi
8+
* @property {function(Object): void} postMessage
9+
* @property {function(): Object} getState
10+
* @property {function(Object): void} setState
11+
*/
12+
13+
;(function () {
14+
/** @type {VsCodeApi} */
15+
// @ts-expect-error - acquireVsCodeApi is provided by VS Code webview API
16+
const vscode = acquireVsCodeApi()
17+
18+
document.addEventListener('DOMContentLoaded', function () {
19+
const copyPatternButton = document.querySelector('.copy-pattern-button')
20+
if (copyPatternButton) {
21+
copyPatternButton.addEventListener('click', function () {
22+
const patternTitle = this.getAttribute('data-pattern-title')
23+
if (patternTitle) {
24+
vscode.postMessage({ type: 'copyPattern', patternTitle: patternTitle })
25+
}
26+
})
27+
}
28+
29+
const refreshButton = document.querySelector('.refresh-button')
30+
if (refreshButton) {
31+
refreshButton.addEventListener('click', function () {
32+
vscode.postMessage({ type: 'refreshIssues' })
33+
})
34+
}
35+
})
36+
})()
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
* {
2+
box-sizing: border-box;
3+
margin: 0;
4+
padding: 0;
5+
}
6+
7+
body {
8+
font-family: var(--vscode-font-family);
9+
font-size: var(--vscode-font-size);
10+
color: var(--vscode-foreground);
11+
background-color: var(--vscode-editor-background);
12+
padding: 40px;
13+
line-height: 1.6;
14+
}
15+
16+
h1 {
17+
font-size: 24px;
18+
font-weight: 500;
19+
color: var(--vscode-foreground);
20+
margin-bottom: 16px;
21+
}
22+
23+
.intro-text {
24+
font-size: 14px;
25+
color: var(--vscode-descriptionForeground);
26+
margin-bottom: 28px;
27+
}
28+
29+
.step-card {
30+
border: 1px solid var(--vscode-panel-border);
31+
border-radius: 8px;
32+
padding: 16px;
33+
margin-bottom: 24px;
34+
}
35+
36+
.step-header {
37+
display: flex;
38+
align-items: center;
39+
margin-bottom: 12px;
40+
}
41+
42+
.step-number {
43+
width: 15px;
44+
height: 15px;
45+
border-radius: 50%;
46+
background-color: var(--vscode-button-background);
47+
color: var(--vscode-button-foreground);
48+
display: flex;
49+
align-items: center;
50+
justify-content: center;
51+
font-weight: 700;
52+
font-size: 9px;
53+
margin-right: 8px;
54+
flex-shrink: 0;
55+
}
56+
57+
.step-title {
58+
font-size: 14px;
59+
font-weight: 600;
60+
color: var(--vscode-foreground);
61+
}
62+
63+
.step-description {
64+
font-size: 14px;
65+
color: var(--vscode-descriptionForeground);
66+
margin-bottom: 16px;
67+
margin-left: 24px;
68+
}
69+
70+
.standards-list {
71+
list-style: none;
72+
padding: 0;
73+
margin: 0;
74+
margin-left: 24px;
75+
}
76+
77+
.standards-list li {
78+
margin-bottom: 16px;
79+
}
80+
81+
.standards-list a {
82+
color: var(--vscode-textLink-foreground);
83+
text-decoration: none;
84+
font-size: 13px;
85+
font-weight: 700;
86+
display: inline-flex;
87+
align-items: center;
88+
}
89+
90+
.standards-list a:hover {
91+
color: var(--vscode-textLink-activeForeground);
92+
}
93+
94+
.standards-list a::after {
95+
content: ' →';
96+
margin-left: 5px;
97+
}
98+
99+
.copy-pattern-button {
100+
display: flex;
101+
align-items: center;
102+
gap: 8px;
103+
background-color: transparent;
104+
border: 1px solid var(--vscode-panel-border);
105+
border-radius: 4px;
106+
padding: 8px;
107+
font-size: 12px;
108+
font-weight: 400;
109+
color: var(--vscode-descriptionForeground);
110+
cursor: pointer;
111+
margin-left: 24px;
112+
}
113+
114+
.copy-icon {
115+
width: 16px;
116+
height: 16px;
117+
color: var(--vscode-descriptionForeground);
118+
flex-shrink: 0;
119+
}
120+
121+
.refresh-button {
122+
background-color: var(--vscode-button-background);
123+
color: var(--vscode-button-foreground);
124+
border: 1px solid var(--vscode-button-border);
125+
padding: 6px 12px;
126+
font-size: 13px;
127+
font-weight: 500;
128+
cursor: pointer;
129+
display: inline-block;
130+
margin-left: 24px;
131+
}
132+
133+
.refresh-button:hover {
134+
background-color: var(--vscode-button-hoverBackground);
135+
}
136+
137+
.help-text {
138+
margin-top: 28px;
139+
font-size: 12px;
140+
color: var(--vscode-descriptionForeground);
141+
}
142+
143+
.help-text a {
144+
color: var(--vscode-textLink-foreground);
145+
text-decoration: none;
146+
}
147+
148+
.help-text a:hover {
149+
color: var(--vscode-textLink-activeForeground);
150+
}

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@
392392
"title": "See CLI issue details",
393393
"category": "Codacy commands"
394394
},
395+
{
396+
"command": "codacy.issue.disablePattern",
397+
"title": "Disable a pattern for this repository",
398+
"category": "Codacy commands"
399+
},
400+
{
401+
"command": "codacy.cliIssue.disablePattern",
402+
"title": "Disable a pattern detected by the CLI for this repository",
403+
"category": "Codacy commands"
404+
},
395405
{
396406
"command": "codacy.configureMCP",
397407
"title": "Configure Codacy MCP Server",

src/extension.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ import { StatusBar } from './views/StatusBar'
1010
import { IssueActionProvider, ProblemsDiagnosticCollection } from './views/ProblemsDiagnosticCollection'
1111
import { Config } from './common/config'
1212
import { AuthUriHandler, codacyAuth } from './auth'
13-
import { IssueDetailsProvider, seeIssueDetailsCommand, seeCliIssueDetailsCommand } from './views/IssueDetailsProvider'
13+
import {
14+
IssueDetailsProvider,
15+
seeIssueDetailsCommand,
16+
seeCliIssueDetailsCommand,
17+
disablePatternCommand,
18+
disableCliPatternCommand,
19+
} from './views/IssueDetailsProvider'
1420
import { PullRequestsTree } from './views/PullRequestsTree'
1521
import { PullRequestNode } from './views/nodes/PullRequestNode'
1622
import { BranchIssuesTree } from './views/BranchIssuesTree'
@@ -92,6 +98,8 @@ const registerCommands = async (context: vscode.ExtensionContext, codacyCloud: C
9298
'codacy.showOutput': () => Logger.outputChannel.show(),
9399
'codacy.issue.seeDetails': seeIssueDetailsCommand,
94100
'codacy.cliIssue.seeDetails': seeCliIssueDetailsCommand,
101+
'codacy.issue.disablePattern': disablePatternCommand,
102+
'codacy.cliIssue.disablePattern': disableCliPatternCommand,
95103
'codacy.installCLI': async () => {
96104
await codacyCloud.cli?.install()
97105
},
@@ -299,7 +307,12 @@ export async function activate(context: vscode.ExtensionContext) {
299307

300308
context.subscriptions.push(AuthUriHandler.register())
301309

302-
context.subscriptions.push(vscode.languages.registerCodeActionsProvider('*', new IssueActionProvider()))
310+
context.subscriptions.push(
311+
vscode.languages.registerCodeActionsProvider(
312+
'*',
313+
new IssueActionProvider(() => codacyCloud.params, codacyCloud.cli)
314+
)
315+
)
303316

304317
context.subscriptions.push(
305318
vscode.workspace.registerTextDocumentContentProvider('codacyIssue', new IssueDetailsProvider())

src/git/CodacyCloud.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Logger from '../common/logger'
44
import Telemetry from '../common/telemetry'
55
import { Config, handleError, parseGitRemote } from '../common'
66
import { Api } from '../api'
7-
import { Branch, OpenAPIError, OrganizationWithMeta, RepositoryWithAnalysis } from '../api/client'
7+
import { Branch, OpenAPIError, OrganizationWithMeta, Provider, RepositoryWithAnalysis } from '../api/client'
88
import { PullRequest, PullRequestInfo } from './PullRequest'
99
import { IssuesManager } from './IssuesManager'
1010
import { checkFirstAnalysisStatus, getRepositoryCodacyCloudStatus } from '../onboarding'
@@ -48,7 +48,7 @@ const LOAD_RETRY_TIME = 2 * 60 * 1000 // 2 minutes
4848
const MAX_LOAD_ATTEMPTS = 5
4949

5050
export interface RepositoryParams {
51-
provider: 'bb' | 'gh' | 'gl'
51+
provider: Provider
5252
organization: string
5353
repository: string
5454
}

0 commit comments

Comments
 (0)