Skip to content

Commit 8d2f7e8

Browse files
committed
refactor: コードの整形と不要な空行を削除
1 parent 92d7fb4 commit 8d2f7e8

File tree

7 files changed

+35
-27
lines changed

7 files changed

+35
-27
lines changed

src/cli/entry.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ program
6262
'Specify the relative path to the config file (from cwd or specified by -d, --dir). Default is .tsgrc.json.',
6363
)
6464
.option('--vue', '(experimental) Enable Vue.js support')
65-
.option('--stdout', 'Output both dependency graph (Mermaid) and code metrics (JSON) to stdout');
65+
.option(
66+
'--stdout',
67+
'Output both dependency graph (Mermaid) and code metrics (JSON) to stdout',
68+
);
6669
program.parse();
6770

6871
const opt = program.opts<OptionValues>();

src/feature/graph/utils.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,34 @@ export function updateChangeStatusFromDiff(base: Graph, head: Graph): void {
3737
function updateNodeChangeStatus(baseNodes: Node[], headNodes: Node[]): void {
3838
// Mark nodes as deleted if they exist in base but not in head
3939
baseNodes.forEach(baseNode => {
40-
const existsInHead = headNodes.some(headNode => isSameNode(baseNode, headNode));
40+
const existsInHead = headNodes.some(headNode =>
41+
isSameNode(baseNode, headNode),
42+
);
4143
if (!existsInHead) {
4244
baseNode.changeStatus = 'deleted';
4345
}
4446
});
4547

4648
// Mark nodes as created if they exist in head but not in base
4749
headNodes.forEach(headNode => {
48-
const existsInBase = baseNodes.some(baseNode => isSameNode(headNode, baseNode));
50+
const existsInBase = baseNodes.some(baseNode =>
51+
isSameNode(headNode, baseNode),
52+
);
4953
if (!existsInBase) {
5054
headNode.changeStatus = 'created';
5155
}
5256
});
5357
}
5458

55-
function updateRelationChangeStatus(baseRelations: Relation[], headRelations: Relation[]): void {
59+
function updateRelationChangeStatus(
60+
baseRelations: Relation[],
61+
headRelations: Relation[],
62+
): void {
5663
// Mark relations as deleted if they exist in base but not in head
5764
baseRelations.forEach(baseRelation => {
5865
if (baseRelation.kind === 'depends_on') {
59-
const existsInHead = headRelations.some(headRelation =>
60-
isSameRelation(baseRelation, headRelation)
66+
const existsInHead = headRelations.some(headRelation =>
67+
isSameRelation(baseRelation, headRelation),
6168
);
6269
if (!existsInHead) {
6370
baseRelation.changeStatus = 'deleted';
@@ -68,8 +75,8 @@ function updateRelationChangeStatus(baseRelations: Relation[], headRelations: Re
6875
// Mark relations as created if they exist in head but not in base
6976
headRelations.forEach(headRelation => {
7077
if (headRelation.kind === 'depends_on') {
71-
const existsInBase = baseRelations.some(baseRelation =>
72-
isSameRelation(headRelation, baseRelation)
78+
const existsInBase = baseRelations.some(baseRelation =>
79+
isSameRelation(headRelation, baseRelation),
7380
);
7481
if (!existsInBase) {
7582
headRelation.changeStatus = 'created';

src/feature/mermaid/directoryTreeBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ function buildDirectoryTree(dirAndNodes: DirAndNodes[]): DirAndNodesTree[] {
9999
item => item.dirHierarchy.length === 1,
100100
);
101101
return rootDirectories.flatMap(buildRecursive);
102-
}
102+
}

src/feature/mermaid/mermaidUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export function fileNameToMermaidId(fileName: string): string {
99

1010
export function fileNameToMermaidName(fileName: string): string {
1111
return fileName.split(/"/).join('//');
12-
}
12+
}

src/feature/mermaid/mermaidWriter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@ function writeChildGraphs(
180180

181181
function writeSubgraphEnd(write: (arg: string) => void, currentIndent: string) {
182182
write(`${currentIndent}end\n`);
183-
}
183+
}

src/usecase/generateTsg/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export async function generateTsg(
6666
const graph = renameGraph
6767
? renameGraph(refineGraph(fullGraph))
6868
: refineGraph(fullGraph);
69-
69+
7070
// Enable metrics automatically for --stdout option
71-
const effectiveOptions = commandOptions.stdout
71+
const effectiveOptions = commandOptions.stdout
7272
? { ...commandOptions, metrics: true }
7373
: commandOptions;
74-
74+
7575
const metrics: CodeMetrics[] = calculateCodeMetrics(
7676
effectiveOptions,
7777
traverser,

src/usecase/generateTsg/writeForAiData.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,22 @@ export function writeForAiData(
2626
): void {
2727
// Dependency Graph section
2828
process.stdout.write('=== DEPENDENCY GRAPH ===\n');
29-
mermaidify(
30-
(str: string) => process.stdout.write(str),
31-
graph,
32-
options,
33-
);
34-
29+
mermaidify((str: string) => process.stdout.write(str), graph, options);
30+
3531
// Code Metrics section
3632
process.stdout.write('\n=== CODE METRICS ===\n');
37-
33+
3834
// Convert metrics to AI-friendly format
3935
const aiMetrics: AiMetrics[] = metrics.map(metric => ({
4036
filePath: metric.filePath,
41-
maintainabilityIndex: Math.round(
42-
(metric.scores.find(s => s.name === 'Maintainability Index')?.value ?? 0) * 100
43-
) / 100,
44-
cyclomaticComplexity:
37+
maintainabilityIndex:
38+
Math.round(
39+
(metric.scores.find(s => s.name === 'Maintainability Index')?.value ??
40+
0) * 100,
41+
) / 100,
42+
cyclomaticComplexity:
4543
metric.scores.find(s => s.name === 'Cyclomatic Complexity')?.value ?? 0,
46-
cognitiveComplexity:
44+
cognitiveComplexity:
4745
metric.scores.find(s => s.name === 'Cognitive Complexity')?.value ?? 0,
4846
}));
4947

@@ -57,4 +55,4 @@ export function writeForAiData(
5755
};
5856

5957
process.stdout.write(JSON.stringify(aiOutput, null, 2));
60-
}
58+
}

0 commit comments

Comments
 (0)