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

Update VS Code for Runtime Analysis Findings Pages #519

Merged
merged 13 commits into from
Dec 9, 2022

Conversation

ahtrotta
Copy link
Contributor

@ahtrotta ahtrotta commented Nov 10, 2022

Fixes #520
This PR uses webviews that are available from this PR

Overview

This PR adds webviews to the VS Code extension that provide information about findings. There are three main changes:

  1. The Runtime Analysis tree view is now organized:

image

  1. There is a Findings Overview page:

image

  1. There is a Finding Details page for each finding:

image

Developing Locally

  1. Build this branch of appmap-js locally.
    a. git clone https:/getappmap/appmap-js.git.
    b. cd appmap-js.
    c. git checkout analysis-findings.
    d. yarn.
    e. yarn build.
  2. Checkout this branch of vscode-appland.
  3. Add this to the bottom of you package.json file in vscode-appland, replacing YOUR_PATH with the path to appmap-js on your machine::
"resolutions": {
    "@appland/components": "portal:<YOUR_PATH>/appmap-js/packages/components",
    "@appland/diagrams": "portal:<YOUR_PATH>/appmap-js/packages/diagrams",
    "@appland/models": "portal:<YOUR_PATH>/appmap-js/packages/models",
    "@appland/openapi": "portal:<YOUR_PATH>/appmap-js/packages/openapi",
    "@appland/scanner": "portal:<YOUR_PATH>/appmap-js/packages/scanner"
  }
  1. Run yarn from the root of vscode-appland.
  2. Run yarn watch from the root of vscode-appland.
  3. Open vscode-appland in VS Code and launch the debugger extension host (press F5 or click the Run menu and then click Start Debugging).

@ahtrotta ahtrotta force-pushed the feat/runtime-analysis-findings-pages branch from 5604f6c to cb32a02 Compare November 18, 2022 20:53
return this.findings().filter((finding) => finding.finding.impactDomain === impactDomain);
}

findingsByHashV2(hash: string): ResolvedFinding[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit-pick, but I think this should just be findingsByHash - The fact that it's V2 is just an implementation detail that may change in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, I renamed it 👍

Comment on lines 114 to 120
const findingsByRuleTitle = this.findings().filter(
(finding) => finding.finding.ruleTitle === ruleTitle
);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can destructure the parameter here to cut down on verbosity (finding.finding). This isn't really an issue though, just an FYI.

filter(({ finding }) => finding.ruleTitle === ruleTitle)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point. I just changed it in a couple of places in this file.

Comment on lines +118 to +130
const uniqueFindingsByHash = findingsByRuleTitle.reduce((accumulator, finding) => {
const hashV2 = finding.finding.hash_v2;

if (!(hashV2 in accumulator)) {
accumulator[hashV2] = finding;
}

return accumulator;
}, {});
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're finding that there's a lot of duplicate logic between the extension and front-end we can consider adding a findings model to @appland/models.

Comment on lines +64 to +68
const impactDomain = finding.finding.impactDomain;

if (impactDomain && !impactDomains.includes(impactDomain)) {
impactDomains.push(impactDomain);
}
Copy link
Contributor

@dustinbyrne dustinbyrne Nov 30, 2022

Choose a reason for hiding this comment

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

Might be worth a case normalization here but I recognize the type is defined as 'Security' | 'Performance' | 'Maintainability' | 'Stability'.

🤷

Comment on lines 90 to 95
const docPath = join(__dirname, `../node_modules/@appland/scanner/doc/rules/${dasherize(id)}.md`);

if (!fs.existsSync(docPath)) return;

// replace any carriage return with a newline
const content = fs.readFileSync(docPath, 'utf-8').replace(/\r\n/g, '\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

The production build is bundled down to a single file, so this path won't exist. Instead of fs.readFileSync, this will need to be a dynamic import.

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need another custom type defined in types/custom.d.ts as well as a webpack loader rule for .md files. This may (?) break our tests as they use tsc compiled JavaScript (not webpack) but we'll cross that bridge when we come to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries, I just changed it so that the rule information is now retrieved from parsing appmap-findings.json instead of looking for the markdown file.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 👍

@ahtrotta ahtrotta force-pushed the feat/runtime-analysis-findings-pages branch 3 times, most recently from 12d3868 to 6a5761b Compare December 2, 2022 20:46
@ahtrotta ahtrotta marked this pull request as ready for review December 6, 2022 22:34
@ahtrotta ahtrotta force-pushed the feat/runtime-analysis-findings-pages branch 3 times, most recently from 198e858 to 40c475d Compare December 7, 2022 00:47
Copy link
Contributor

@dustinbyrne dustinbyrne left a comment

Choose a reason for hiding this comment

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

Looks great.

@dustinbyrne dustinbyrne force-pushed the feat/runtime-analysis-findings-pages branch from 99376fb to ac9b664 Compare December 9, 2022 21:42
@dustinbyrne dustinbyrne merged commit 88f3df8 into master Dec 9, 2022
@dustinbyrne dustinbyrne deleted the feat/runtime-analysis-findings-pages branch December 9, 2022 21:56
appland-release pushed a commit that referenced this pull request Dec 13, 2022
# [0.56.0](v0.55.0...v0.56.0) (2022-12-13)

### Features

* Add dashboard and details pages for Runtime Analysis ([#519](#519)) ([88f3df8](88f3df8))
* Prompt the user to sign in before viewing instructions if they're not authenticated ([3827287](3827287))
@appland-release
Copy link
Contributor

🎉 This PR is included in version 0.56.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Update VS Code for Runtime Analysis Findings Pages
3 participants