diff --git a/.gitignore b/.gitignore index be2ea3b..f0ec0d4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/** vsc-extension-quickstart.md *.vsix _NOTEPAD.md +_ROADMAP.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e8dade..e268db4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,25 @@ # Change Log -All notable changes to the "string-checker-js" extension will be documented in this file. +*All notable changes to the "string-checker-js" extension will be documented in this file.* +*The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).* -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Known Issues + +Here are a few common issues. + +- String detection by language provider is based on statistical analysis. The longer the string, the more accurate the detection. ## [Unreleased] +## [0.0.2] + +- Formatting in README file. +- "Release Notes" section removed from README file. +- "Known Issues" section mode from README to CHANGELOG file. +- Code provider improvement (environment variable detection). +- Class provider improvement (`rgb()` javascript statement detection). +- Code refactoring. + ## [0.0.1] - Initial release. diff --git a/README.md b/README.md index 6f3f853..813c1ca 100755 --- a/README.md +++ b/README.md @@ -38,8 +38,6 @@ Strings are evaluated by different providers, each being dedicated to a specific The `string.checker.js.testString` [command](#extension-settings) brings a convenient way to test all providers for a given string. - - ![demo-test-string](https://raw.githubusercontent.com/michelcaradec/string-checker-js/master/readme_assets/demo-test-string.gif) ## Requirements @@ -66,19 +64,7 @@ This extension contributes the following settings: - `string.checker.js.testString`: test a string with all detection [providers](#detection-providers). - `string.checker.js.showVersion`: display String Checker JS version. -- [1] **Path exclusion** is based on the full path (`/path/to/my/file.js`), while **name exclusion** only uses the last part (`file.js`for a file, `my`for a folder), which means if the same name is found in another folder, it will be excluded too. - -## Known Issues - -Here are a few common issues. - -- String detection by language provider is based on statistical analysis. The longer the string, the more accurate the detection. - -## Release Notes - -### 0.0.1 - -Initial release. +- [1] **Path exclusion** is based on the full path (`/path/to/my/file.js`), while **name exclusion** only uses the last part (`file.js` for a file, `my` for a folder), which means if the same name is found in another folder, it will be excluded too. ## Mentions diff --git a/package.json b/package.json index 6c2a4ff..d3b751f 100755 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/michelcaradec/string-checker-js" }, "license": "MIT", - "version": "0.0.1", + "version": "0.0.2", "engines": { "vscode": "^1.38.0" }, diff --git a/readme_assets/demo-test-string.gif b/readme_assets/demo-test-string.gif index 9b9c4ad..5a065ed 100644 Binary files a/readme_assets/demo-test-string.gif and b/readme_assets/demo-test-string.gif differ diff --git a/src/checker/providers/classNameProvider.ts b/src/checker/providers/classNameProvider.ts index f6910b3..d6cf8bb 100755 --- a/src/checker/providers/classNameProvider.ts +++ b/src/checker/providers/classNameProvider.ts @@ -11,6 +11,10 @@ export class ClassNameDetect implements IDetectProvider { return [ConfidenceLevel.Technical, 'javascript']; } + if (/^rgba?\([\d\s,\.]+\)$/m.test(text)) { + return [ConfidenceLevel.Technical, 'javascript']; + } + if (text.search(/fa[rs]? fa(-[^-]*)*/g) >= 0) { return [ConfidenceLevel.Technical, 'font awesome']; } diff --git a/src/checker/providers/codeDetect.ts b/src/checker/providers/codeDetect.ts index 405d7c7..f772e00 100755 --- a/src/checker/providers/codeDetect.ts +++ b/src/checker/providers/codeDetect.ts @@ -57,6 +57,11 @@ export class CodeDetect implements IDetectProvider { return [ConfidenceLevel.Technical, 'html']; } + if (/^[A-Z_][A-Z\d_]+$/.test(text)) { + // Environment variable. + return [ConfidenceLevel.Technical, 'env']; + } + const posSpace = text.search(/\s/g); if (posSpace < 0) { // No white space... @@ -84,8 +89,6 @@ export class CodeDetect implements IDetectProvider { } } - // FIXME: Exclude environment variables (`MONGODB_URI_LOCAL`). - return [ConfidenceLevel.Unknown, '']; } diff --git a/src/checker/providers/keywordsDetect.ts b/src/checker/providers/keywordsDetect.ts index fa394c2..0fa0ce1 100755 --- a/src/checker/providers/keywordsDetect.ts +++ b/src/checker/providers/keywordsDetect.ts @@ -8,8 +8,6 @@ export class KeywordsDetect implements IDetectProvider { private _messageList: UserDictionary; constructor() { - // FIXME: Substitute `||` with coalesce operator `??` when TypeScript 3.7 will be available. - // https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/ this._technicalList = UserDictionaryFactory.createInstance(DictionaryType.ExcludeToken) || new UserDictionary(); this._messageList = UserDictionaryFactory.createInstance(DictionaryType.IncludeToken) || new UserDictionary(); } diff --git a/src/checker/providers/languageDetect.ts b/src/checker/providers/languageDetect.ts index 8d57288..d46ffc0 100755 --- a/src/checker/providers/languageDetect.ts +++ b/src/checker/providers/languageDetect.ts @@ -16,7 +16,6 @@ export class LanguageDetect implements IDetectProvider { const languages: [[string, number]] = franc.all(text, { only: filter }); const language: string = languages[0][0]; - // FIXME: Details on detected language are somewhat confusing (especially for short strings) and might not be relevant to display. return language === UndefinedLanguage ? [ConfidenceLevel.Unknown, ''] : [ConfidenceLevel.Message, `lang=${language}`]; } } diff --git a/src/commands.ts b/src/commands.ts index e5c481c..412de02 100755 --- a/src/commands.ts +++ b/src/commands.ts @@ -215,7 +215,6 @@ export class Commands { } static async filterTokens(tree: TreeProvider): Promise { - // FIXME: Make filter command icon reflect filtered state. const text = await vscode.window.showInputBox({ value: tree.filter, prompt: Messages.FilterToken, placeHolder: Messages.EnterString }); if (text === undefined) { return; diff --git a/src/constants.ts b/src/constants.ts index 7ba3836..43b2f80 100755 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,6 @@ export class Constants { static readonly ExtensionName = 'string-checker-js'; - static readonly ExtensionVersion = 'v0.0.1'; + static readonly ExtensionVersion = 'v0.0.2'; static readonly ExtensionID = 'string-checker-js'; static readonly ItemStringPrefix = 'string:'; static readonly ItemRegexPrefix = 'regex:'; diff --git a/src/extension.ts b/src/extension.ts index 6c30b2e..da758ee 100755 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,9 +7,6 @@ export function activate(context: vscode.ExtensionContext) { const tree = new TreeProvider(); const treeView = vscode.window.createTreeView('string-checker-js-view', { treeDataProvider: tree}); - // TODO: provide sample files (activating all providers) - // TODO: (v2) scanDocumentsInFolder. Requires command on File Explorer items. - // TODO: (v2) Search bar in TreeView to filter items by text. context.subscriptions.push( vscode.window.registerTreeDataProvider('string-checker-js-view', tree), treeView, diff --git a/src/tree/treeProvider.ts b/src/tree/treeProvider.ts index 14e69a2..d159dbf 100755 --- a/src/tree/treeProvider.ts +++ b/src/tree/treeProvider.ts @@ -97,8 +97,6 @@ export class TreeProvider implements vscode.TreeDataProvider { //#region Filter - // TODO (v2) : Use `TreeItemLabel` (see VSCode Insider version) when available to highlight tree items when in filtered state. - private _filter?: string; get filter(): string | undefined { @@ -143,7 +141,6 @@ export class TreeProvider implements vscode.TreeDataProvider { return undefined; } else if (this._files.length > 0) { // Files - // FIXME: Files with no tokens (in filtered view) will still be displayed. const sorted = this._files.sort((a, b) => a.label!.localeCompare(b.label!)); sorted.forEach(it => it.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed); @@ -189,20 +186,6 @@ export class TreeProvider implements vscode.TreeDataProvider { } } - // private getConnectedItems(item: vscode.TreeItem): vscode.TreeItem[] { - // if (item instanceof TreeItemFile) { - // const file = item; - // return this.tokens.filter(it => it.file === file); - // } else if (item instanceof TreeItemToken) { - // const token = item; - // // Files where this token appears - // return this.tokens.filter(it => it.label === token.label) - // .map(it => TreeItemFile.CreateT2FInstance(it.file!.uri, it.token!.positions)); - // } else { - // return []; - // } - // } - getTreeItem(element: any): vscode.TreeItem | Thenable { return element; }