Skip to content

Commit b29ed61

Browse files
committed
chore: fix formatting
1 parent 9734ad9 commit b29ed61

File tree

6 files changed

+59
-39
lines changed

6 files changed

+59
-39
lines changed

packages/angular-mcp-server/src/lib/tools/ds/report-violations/group-violations.tool.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,20 @@ export const groupViolationsHandler = createHandler<
5353

5454
// Detect format and convert if necessary
5555
const format = detectReportFormat(rawData);
56-
56+
5757
if (format === 'unknown') {
5858
throw new Error(
5959
'Invalid violations report format. Expected either { files: [...] } or { components: [...] }',
6060
);
6161
}
6262

6363
let violationsData: AllViolationsReportByFile;
64-
64+
6565
if (format === 'component') {
6666
// Convert component-grouped to file-grouped format
67-
violationsData = convertComponentToFileFormat(rawData as AllViolationsReport);
67+
violationsData = convertComponentToFileFormat(
68+
rawData as AllViolationsReport,
69+
);
6870
} else {
6971
violationsData = rawData as AllViolationsReportByFile;
7072
}
@@ -94,12 +96,8 @@ export const groupViolationsHandler = createHandler<
9496
);
9597

9698
const targetPerGroup = totalViolations / optimalGroups;
97-
const minAcceptable = Math.floor(
98-
targetPerGroup * (1 - variance / 100),
99-
);
100-
const maxAcceptable = Math.ceil(
101-
targetPerGroup * (1 + variance / 100),
102-
);
99+
const minAcceptable = Math.floor(targetPerGroup * (1 - variance / 100));
100+
const maxAcceptable = Math.ceil(targetPerGroup * (1 + variance / 100));
103101

104102
// Create work groups
105103
const groups = createWorkGroups(

packages/angular-mcp-server/src/lib/tools/ds/report-violations/report-all-violations.tool.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function processAudits(
5252
fileGroups,
5353
)) {
5454
// Lines are already sorted by groupIssuesByFile, so we can use them directly
55-
const { violation, replacement } = parseViolationMessageWithReplacement(message);
55+
const { violation, replacement } =
56+
parseViolationMessageWithReplacement(message);
5657

5758
processed.push({
5859
component: componentName,
@@ -96,10 +97,16 @@ export const reportAllViolationsHandler = createHandler<
9697

9798
// Early exit for empty results
9899
if (failedAudits.length === 0) {
99-
const report = params.groupBy === 'file' ? { files: [] } : { components: [] };
100-
100+
const report =
101+
params.groupBy === 'file' ? { files: [] } : { components: [] };
102+
101103
if (params.saveAsFile) {
102-
const outputDir = join(cwd, 'tmp', '.angular-toolkit-mcp', 'violations-report');
104+
const outputDir = join(
105+
cwd,
106+
'tmp',
107+
'.angular-toolkit-mcp',
108+
'violations-report',
109+
);
103110
const filename = generateFilename(params.directory);
104111
const filePath = join(outputDir, filename);
105112
await mkdir(outputDir, { recursive: true });
@@ -114,7 +121,7 @@ export const reportAllViolationsHandler = createHandler<
114121
},
115122
};
116123
}
117-
124+
118125
return report;
119126
}
120127

@@ -149,14 +156,19 @@ export const reportAllViolationsHandler = createHandler<
149156
const report = { components };
150157

151158
if (params.saveAsFile) {
152-
const outputDir = join(cwd, 'tmp', '.angular-toolkit-mcp', 'violations-report');
159+
const outputDir = join(
160+
cwd,
161+
'tmp',
162+
'.angular-toolkit-mcp',
163+
'violations-report',
164+
);
153165
const filename = generateFilename(params.directory);
154166
const filePath = join(outputDir, filename);
155167
await mkdir(outputDir, { recursive: true });
156168
await writeFile(filePath, JSON.stringify(report, null, 2), 'utf-8');
157-
169+
158170
const stats = calculateComponentGroupedStats(components);
159-
171+
160172
return {
161173
message: 'Violations report saved',
162174
filePath: toWorkspaceRelativePath(filePath, workspaceRoot),
@@ -195,14 +207,19 @@ export const reportAllViolationsHandler = createHandler<
195207
const report = { files };
196208

197209
if (params.saveAsFile) {
198-
const outputDir = join(cwd, 'tmp', '.angular-toolkit-mcp', 'violations-report');
210+
const outputDir = join(
211+
cwd,
212+
'tmp',
213+
'.angular-toolkit-mcp',
214+
'violations-report',
215+
);
199216
const filename = generateFilename(params.directory);
200217
const filePath = join(outputDir, filename);
201218
await mkdir(outputDir, { recursive: true });
202219
await writeFile(filePath, JSON.stringify(report, null, 2), 'utf-8');
203-
220+
204221
const stats = calculateFileGroupedStats(files);
205-
222+
206223
return {
207224
message: 'Violations report saved',
208225
filePath: toWorkspaceRelativePath(filePath, workspaceRoot),
@@ -216,7 +233,7 @@ export const reportAllViolationsHandler = createHandler<
216233
// Check if this is a file output response
217234
if ('message' in result && 'filePath' in result) {
218235
const stats = 'stats' in result && result.stats ? result.stats : null;
219-
const statsMessage = stats
236+
const statsMessage = stats
220237
? ` (${stats.components} components, ${stats.files} files, ${stats.lines} lines)`
221238
: '';
222239
return [`Violations report saved to ${result.filePath}${statsMessage}`];

packages/angular-mcp-server/src/lib/tools/ds/report-violations/report-violations.tool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ export const reportViolationsHandler = createHandler<
101101
const filePath = join(outputDir, filename);
102102
await mkdir(outputDir, { recursive: true });
103103
await writeFile(filePath, JSON.stringify(report, null, 2), 'utf-8');
104-
104+
105105
const stats = calculateSingleComponentStats(violations);
106-
106+
107107
return {
108108
message: 'Violations report saved',
109109
filePath: toWorkspaceRelativePath(filePath, workspaceRoot),
@@ -117,7 +117,7 @@ export const reportViolationsHandler = createHandler<
117117
// Check if this is a file output response
118118
if ('message' in result && 'filePath' in result) {
119119
const stats = 'stats' in result ? result.stats : null;
120-
const statsMessage = stats
120+
const statsMessage = stats
121121
? ` (${stats.components} component, ${stats.files} files, ${stats.lines} lines)`
122122
: '';
123123
return [`Violations report saved to ${result.filePath}${statsMessage}`];

packages/angular-mcp-server/src/lib/tools/ds/report-violations/utils/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ export {
1313
detectReportFormat,
1414
convertComponentToFileFormat,
1515
} from './format-converter.utils.js';
16-
export {
17-
calculateViolations,
18-
enrichFiles,
19-
} from './file-enrichment.utils.js';
16+
export { calculateViolations, enrichFiles } from './file-enrichment.utils.js';
2017
export type { EnrichedFile } from './file-enrichment.utils.js';
2118
export {
2219
groupByDirectory,

packages/angular-mcp-server/src/lib/tools/ds/report-violations/utils/stats.utils.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ViolationEntry, AllViolationsComponentReport, FileViolationReport } from '../models/types.js';
1+
import type {
2+
ViolationEntry,
3+
AllViolationsComponentReport,
4+
FileViolationReport,
5+
} from '../models/types.js';
26

37
export interface ViolationStats {
48
components: number;
@@ -12,9 +16,9 @@ export interface ViolationStats {
1216
export function calculateSingleComponentStats(
1317
violations: ViolationEntry[],
1418
): ViolationStats {
15-
const uniqueFiles = new Set(violations.map(v => v.file)).size;
19+
const uniqueFiles = new Set(violations.map((v) => v.file)).size;
1620
const totalLines = violations.reduce((sum, v) => sum + v.lines.length, 0);
17-
21+
1822
return {
1923
components: 1,
2024
files: uniqueFiles,
@@ -30,13 +34,13 @@ export function calculateComponentGroupedStats(
3034
): ViolationStats {
3135
const uniqueComponents = components.length;
3236
const uniqueFiles = new Set(
33-
components.flatMap(c => c.violations.map(v => v.file))
37+
components.flatMap((c) => c.violations.map((v) => v.file)),
3438
).size;
3539
const totalLines = components.reduce(
3640
(sum, c) => sum + c.violations.reduce((s, v) => s + v.lines.length, 0),
37-
0
41+
0,
3842
);
39-
43+
4044
return {
4145
components: uniqueComponents,
4246
files: uniqueFiles,
@@ -51,14 +55,14 @@ export function calculateFileGroupedStats(
5155
files: FileViolationReport[],
5256
): ViolationStats {
5357
const uniqueComponents = new Set(
54-
files.flatMap(f => f.components.map(c => c.component))
58+
files.flatMap((f) => f.components.map((c) => c.component)),
5559
).size;
5660
const uniqueFiles = files.length;
5761
const totalLines = files.reduce(
5862
(sum, f) => sum + f.components.reduce((s, c) => s + c.lines.length, 0),
59-
0
63+
0,
6064
);
61-
65+
6266
return {
6367
components: uniqueComponents,
6468
files: uniqueFiles,

packages/angular-mcp-server/src/lib/tools/ds/report-violations/utils/work-group.utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export interface WorkGroup {
1313
/**
1414
* Assign group name based on primary directory
1515
*/
16-
export function assignGroupName(directories: string[], groupId: number): string {
16+
export function assignGroupName(
17+
directories: string[],
18+
groupId: number,
19+
): string {
1720
const primaryDir = directories[0] || 'misc';
1821
return `Group ${groupId} - ${primaryDir}`;
1922
}
@@ -66,7 +69,8 @@ export function createWorkGroups(
6669
.filter((g) => g.violations + dir.violations <= maxAcceptable)
6770
.sort((a, b) => a.violations - b.violations)[0];
6871

69-
const selectedGroup = targetGroup || groups.sort((a, b) => a.violations - b.violations)[0];
72+
const selectedGroup =
73+
targetGroup || groups.sort((a, b) => a.violations - b.violations)[0];
7074

7175
selectedGroup.directories.push(dir.directory);
7276
selectedGroup.files.push(...dir.files);

0 commit comments

Comments
 (0)