-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CHANGE @W-17397505@ Added core version to certain outputs #172
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ export enum OutputFormat { | |
SARIF = "SARIF" | ||
} | ||
|
||
export const CODE_ANALYZER_CORE_NAME: string = 'code-analyzer'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If memory serves, this was the name we agreed on, and it means all our conventions for engine names (lowercase, skewer-case, etc). |
||
|
||
export abstract class OutputFormatter { | ||
abstract format(results: RunResults): string | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import {getMessage} from "./messages"; | |
import {Clock, RealClock, toAbsolutePath} from "./utils"; | ||
import {OutputFormat, OutputFormatter} from "./output-format"; | ||
import path from "node:path"; | ||
import fs from "node:fs"; | ||
|
||
export interface CodeLocation { | ||
getFile(): string | undefined | ||
|
@@ -32,6 +33,7 @@ export interface EngineRunResults { | |
|
||
export interface RunResults { | ||
getRunDirectory(): string | ||
getCoreVersion(): string | ||
getViolationCount(): number | ||
getViolationCountOfSeverity(severity: SeverityLevel): number | ||
getViolations(): Violation[] | ||
|
@@ -238,17 +240,27 @@ export class UnexpectedErrorEngineRunResults implements EngineRunResults { | |
export class RunResultsImpl implements RunResults { | ||
private readonly clock: Clock; | ||
private readonly runDir: string; | ||
private coreVersion: string = ''; // This value will be overwritten before it ever has a chance to matter. | ||
private readonly engineRunResultsMap: Map<string, EngineRunResults> = new Map(); | ||
|
||
constructor(clock: Clock = new RealClock(), runDir: string = process.cwd() + path.sep) { | ||
this.clock = clock; | ||
this.runDir = runDir; | ||
} | ||
|
||
getRunDirectory() { | ||
getRunDirectory(): string { | ||
return this.runDir; | ||
} | ||
|
||
getCoreVersion(): string { | ||
if (!this.coreVersion) { | ||
const pathToPackageJson: string = path.join(__dirname, '..', 'package.json'); | ||
const packageJson: { version: string } = JSON.parse(fs.readFileSync(pathToPackageJson, 'utf-8')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm using |
||
this.coreVersion = packageJson.version; | ||
} | ||
return this.coreVersion; | ||
} | ||
|
||
getViolations(): Violation[] { | ||
return Array.from(this.engineRunResultsMap.values()).flatMap( | ||
engineRunResults => engineRunResults.getViolations()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
"sev4": 0, | ||
"sev5": 0 | ||
}, | ||
"versions": {}, | ||
"versions": { | ||
"code-analyzer": "{{CORE_VERSION}}" | ||
}, | ||
"violations": [] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure whether we wanted to do an
0.20.0
for this or an0.19.2
. I'm fine with either.