Skip to content

Commit

Permalink
fix: change maintinability calculate source, CognitiveComplexity to C…
Browse files Browse the repository at this point in the history
…yclomaticComplexity. Because strict define using CyclomaticComplexity.
  • Loading branch information
ytetsuro committed Aug 14, 2022
1 parent 24494d2 commit 3104f84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Analyzer/CodeMetricsCalculator/Maintainability/Calculator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Maintainability } from './Maintainability';
import { HalsteadVolume } from '../Halstead/MetricsValue/HalsteadVolume';
import { CognitiveComplexity } from '../CognitiveComplexity/CognitiveComplexity';
import { LogicalLineOfCode } from '../LineOfCode/MetricsValue/LogicalLineOfCode';
import { MetricsValue } from '../../Metrics/MetricsValue';
import { Metrics } from '../../Metrics/Metrics';
import { CodePointType } from '../../Metrics/CodePointType';
import { injectable } from 'inversify';
import { CyclomaticComplexity } from '../CyclomaticComplexity/CyclomaticComplexity';

type TargetMetrics = HalsteadVolume | LogicalLineOfCode | CognitiveComplexity;
type TargetMetrics = HalsteadVolume | LogicalLineOfCode | CyclomaticComplexity;

@injectable()
export class Calculator {
readonly targetMetrics = [HalsteadVolume, LogicalLineOfCode, CognitiveComplexity];
readonly targetMetrics = [HalsteadVolume, LogicalLineOfCode, CyclomaticComplexity];

analyze(metricsList: Metrics[]): Metrics[] {
return metricsList
Expand All @@ -28,8 +28,8 @@ export class Calculator {
calculate(metricsList: MetricsValue[]): MetricsValue[] {
const halsteadVolume = <HalsteadVolume>metricsList.find((row) => row instanceof HalsteadVolume)!;
const logicalLineOfCode = <LogicalLineOfCode>metricsList.find((row) => row instanceof LogicalLineOfCode)!;
const cognitiveComplexity = <CognitiveComplexity>metricsList.find((row) => row instanceof CognitiveComplexity)!;
const cyclomaticComplexity = <CyclomaticComplexity>metricsList.find((row) => row instanceof CyclomaticComplexity)!;

return [new Maintainability(halsteadVolume, cognitiveComplexity, logicalLineOfCode)];
return [new Maintainability(halsteadVolume, cyclomaticComplexity, logicalLineOfCode)];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Decimal } from 'decimal.js';
import { MetricsType } from '../../Metrics/MetricsType';
import { MetricsValue } from '../../Metrics/MetricsValue';
import { HalsteadVolume } from '../Halstead/MetricsValue/HalsteadVolume';
import { CognitiveComplexity } from '../CognitiveComplexity/CognitiveComplexity';
import { LogicalLineOfCode } from '../LineOfCode/MetricsValue/LogicalLineOfCode';
import { CyclomaticComplexity } from '../CyclomaticComplexity/CyclomaticComplexity';

export class Maintainability implements MetricsValue {
public readonly type = MetricsType.Maintainability;
constructor(
private readonly halsteadVolume: HalsteadVolume,
private readonly complexity: CognitiveComplexity,
private readonly complexity: CyclomaticComplexity,
private readonly logicalLineOfCode: LogicalLineOfCode
) {}

Expand Down

0 comments on commit 3104f84

Please sign in to comment.