Skip to content
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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

jfeingold35
Copy link
Contributor

@jfeingold35 jfeingold35 commented Dec 13, 2024

Adds the code-analyzer-core version to certain output formats, with the name "code-analyzer" and the value being pulled from Core's package.json version property.
The outputs affected are:

  • XML
  • JSON
  • HTML (indirectly via JSON)

I chose not to include it in SARIF because I couldn't figure out a good place to slot it into the schema, since It's not technically a tool that has violations or rules associated with it.

@@ -1,7 +1,7 @@
{
"name": "@salesforce/code-analyzer-core",
"description": "Core Package for the Salesforce Code Analyzer",
"version": "0.19.1",
"version": "0.20.0-SNAPSHOT",
Copy link
Contributor Author

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 an 0.19.2. I'm fine with either.

@@ -14,6 +14,8 @@ export enum OutputFormat {
SARIF = "SARIF"
}

export const CODE_ANALYZER_CORE_NAME: string = 'code-analyzer';
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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).

getCoreVersion(): string {
if (!this.coreVersion) {
const pathToPackageJson: string = path.join(__dirname, '..', 'package.json');
const packageJson: { version: string } = JSON.parse(fs.readFileSync(pathToPackageJson, 'utf-8'));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using fs.readFileSync() here instead of a Promise because I wanted to keep the results formatting a synchronous process instead of introducing awaits everywhere.
We cache the result to make sure we only do the read once, so there shouldn't be a noticeable impact on performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant