Skip to content

Commit

Permalink
v0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
KamasamaK committed Apr 16, 2022
1 parent 69aa2af commit 877391d
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 659 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
"env": {
"es2017": true,
"es2021": true,
"node": true
},
"parser": "@typescript-eslint/parser",
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ jobs:
tag: ${{ steps.setup-tag.outputs.tag }}
version: ${{ steps.setup-tag.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Checkout source
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
Expand All @@ -47,7 +50,8 @@ jobs:
run: |
npx vsce package --out ${{ steps.setup.outputs.packageName }}
- uses: actions/upload-artifact@v3
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: ${{ steps.setup.outputs.packageName }}
path: ./${{ steps.setup.outputs.packageName }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.history/
.sonarlint/
.vscode/cSpell.json
.DS_Store
Thumbs.db
node_modules/
out/
dist/
*.vsix
6 changes: 3 additions & 3 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ out/test/**
test/**
src/**
**/*.map
.gitignore
.eslintignore
.eslintrc.js
**/.gitignore
**/.eslintignore
**/.eslintrc.js
.markdownlint.json
tsconfig.json
webpack.config.js
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the VS Code CFLint extension will be documented in this file.

## [0.3.6] - 2022-04-16

- Add Workspace Trust support

## [0.3.5] - 2022-04-07

- Utilize output channel
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Used in Command Palette (`Ctrl`+`Shift`+`P`). Alternatively, can be bound to Key

- Output CFLint XML file for currently active document

_Note_: The output commands above have CFLint produce the reports directly, so some extension settings are not considered.
*Note*: The output commands above have CFLint produce the reports directly, so some extension settings are not considered.

## Known Issues/Limitations

Expand Down
857 changes: 232 additions & 625 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 18 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "vscode-cflint",
"displayName": "CFLint",
"description": "CFLint for Visual Studio Code",
"version": "0.3.5",
"version": "0.3.6",
"author": "KamasamaK",
"publisher": "KamasamaK",
"license": "MIT",
"engines": {
"vscode": "^1.66.1"
"vscode": "^1.66.2"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -35,6 +35,16 @@
"onCommand:cflint.runLinter"
],
"main": "./out/src/extension",
"capabilities": {
"virtualWorkspaces": {
"supported": false,
"description": "Using CFLint is not possible in virtual workspaces."
},
"untrustedWorkspaces": {
"supported": false,
"description": "The extension requires workspace trust because it loads configuration files and code from the workspace and executes it."
}
},
"contributes": {
"configuration": {
"id": "cflint",
Expand Down Expand Up @@ -308,10 +318,10 @@
"vscode:prepublish": "npm run build"
},
"dependencies": {
"@octokit/rest": "~17.11.2",
"@octokit/rest": "~18.12.0",
"findup-sync": "5.0.0",
"micromatch": "4.0.5",
"semver": "~7.3.6",
"semver": "~7.3.7",
"camelcase": "6.3.0",
"uppercamelcase": "3.0.0"
},
Expand All @@ -323,10 +333,10 @@
"@types/mocha": "~9.1.0",
"@types/node": "~16.11.26",
"@types/vscode": "~1.66.0",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"eslint": "^8.12.0",
"eslint-plugin-jsdoc": "^38.1.6",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"eslint": "^8.13.0",
"eslint-plugin-jsdoc": "^39.2.1",
"mocha": "~9.2.2",
"rimraf": "^3.0.2",
"typescript": "^4.6.3",
Expand Down
15 changes: 5 additions & 10 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import findup from "findup-sync";
import * as fs from "fs";
import * as path from "path";
import { Position, Range, TextDocument, Uri, window, workspace, WorkspaceConfiguration, WorkspaceEdit, TextEditor } from "vscode";
import { getCFLintSettings } from "./extension";
Expand Down Expand Up @@ -94,16 +93,12 @@ async function createDefaultConfiguration(directory: Uri): Promise<boolean> {
* @param resource The resource for which to check the settings
* @return Whether cflint.altConfigFile resolves to a valid path.
*/
function alternateConfigFileExists(resource: Uri): boolean {
async function alternateConfigFileExists(resource: Uri): Promise<boolean> {
const cflintSettings: WorkspaceConfiguration = getCFLintSettings(resource);
const altConfigFilePath: string = cflintSettings.get<string>("altConfigFile.path", "");

/* TODO: Replace with fileExists when converted to async
const altConfigFileUri = Uri.file(altConfigFilePath);
return fileExists(altConfigFileUri);
*/

return fs.existsSync(altConfigFilePath);
return fileExists(altConfigFileUri);
}

/**
Expand All @@ -113,11 +108,11 @@ function alternateConfigFileExists(resource: Uri): boolean {
* @param fileName The filename that will be checked.
* @return The full path to the config file, or undefined if none.
*/
export function getConfigFilePath(document: TextDocument, fileName: string = CONFIG_FILENAME): string {
export async function getConfigFilePath(document: TextDocument, fileName: string = CONFIG_FILENAME): Promise<string> {
const cflintSettings: WorkspaceConfiguration = getCFLintSettings(document.uri);
const altConfigFile: string = cflintSettings.get<string>("altConfigFile.path", "");
const altConfigFileUsage: string = cflintSettings.get<string>("altConfigFile.usage", "fallback");
const altConfigFileExists: boolean = alternateConfigFileExists(document.uri);
const altConfigFileExists: boolean = await alternateConfigFileExists(document.uri);

if (altConfigFileExists && altConfigFileUsage === "always") {
return altConfigFile;
Expand Down Expand Up @@ -158,7 +153,7 @@ export function parseConfig(configDocument: TextDocument): Config {
* @param document The document from which to determine the active config
*/
export async function getActiveConfig(document: TextDocument = window.activeTextEditor.document): Promise<TextDocument | undefined> {
const currentConfigPath = getConfigFilePath(document);
const currentConfigPath = await getConfigFilePath(document);
if (currentConfigPath) {
return workspace.openTextDocument(currentConfigPath);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function makeDiagnostic(document: TextDocument, issue: CFLintIssue): Diagnostic
issue.column = Math.max(issue.column, 0);

const start: Position = new Position(issue.line - 1, issue.column);
// TODO: Try using offset instead
// TODO: Investigate using offset instead
// const offsetStart: Position = document.positionAt(issue.offset);
const wordRange: Range = document.getWordRangeAtPosition(start);
const diagnosticRange: Range = wordRange ?? new Range(start, start);
Expand Down
12 changes: 5 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { fileExists } from "./utils/fileUtils";
const octokit = new Octokit();
const gitRepoInfo = {
owner: "cflint",
repo: "CFLint",
defaultBranch: "master"
repo: "CFLint"
};
const httpSuccessStatusCode = 200;

Expand Down Expand Up @@ -460,8 +459,7 @@ async function onLintDocument(document: TextDocument): Promise<void> {

const javaExecutable: string = await findJavaExecutable(document.uri);

// TODO: Check for workspace. Try workspace.workspaceFolders[0].uri.fsPath
const options = workspace.rootPath ? { cwd: workspace.rootPath } : undefined;
const options = workspace.workspaceFolders?.[0] ? { cwd: workspace.workspaceFolders[0].uri.fsPath } : undefined;
const javaArgs: string[] = [
"-jar",
cflintSettings.get<string>("jarPath", ""),
Expand All @@ -475,7 +473,7 @@ async function onLintDocument(document: TextDocument): Promise<void> {

const altConfigFile: string = cflintSettings.get<string>("altConfigFile.path", "");
if (altConfigFile) {
const configFile: string = getConfigFilePath(document);
const configFile: string = await getConfigFilePath(document);
if (configFile) {
javaArgs.push("-configfile", configFile);
}
Expand Down Expand Up @@ -586,7 +584,7 @@ async function outputLintDocument(document: TextDocument, format: OutputFormat =

const altConfigFile: string = cflintSettings.get<string>("altConfigFile.path", "");
if (altConfigFile) {
const configFile: string = getConfigFilePath(document);
const configFile: string = await getConfigFilePath(document);
if (configFile) {
javaArgs.push("-configfile", configFile);
}
Expand Down Expand Up @@ -719,7 +717,7 @@ async function showRuleDocumentation(_ruleId?: string): Promise<void> {
});

if (cflintRulesResult?.status === httpSuccessStatusCode && !Array.isArray(cflintRulesResult.data) && cflintRulesResult.data.type === "file") {
const result = Buffer.from(cflintRulesResult.data.content, cflintRulesResult.data.encoding as BufferEncoding);
const result = Buffer.from(cflintRulesResult.data["content"], cflintRulesResult.data["encoding"] as BufferEncoding);

await workspace.fs.writeFile(cflintRulesUri, result);

Expand Down

0 comments on commit 877391d

Please sign in to comment.