Skip to content

Commit

Permalink
Updates for v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
michelcaradec committed Oct 30, 2019
1 parent f961e07 commit 356863d
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/**
vsc-extension-quickstart.md
*.vsix
_NOTEPAD.md
_ROADMAP.md
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- TODO: Image URLs in README.md and CHANGELOG.md need to resolve to https URLs. -->

![demo-test-string](https://raw.githubusercontent.com/michelcaradec/string-checker-js/master/readme_assets/demo-test-string.gif)

## Requirements
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Binary file modified readme_assets/demo-test-string.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/checker/providers/classNameProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
7 changes: 5 additions & 2 deletions src/checker/providers/codeDetect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -84,8 +89,6 @@ export class CodeDetect implements IDetectProvider {
}
}

// FIXME: Exclude environment variables (`MONGODB_URI_LOCAL`).

return [ConfidenceLevel.Unknown, ''];
}

Expand Down
2 changes: 0 additions & 2 deletions src/checker/providers/keywordsDetect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 0 additions & 1 deletion src/checker/providers/languageDetect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`];
}
}
1 change: 0 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export class Commands {
}

static async filterTokens(tree: TreeProvider): Promise<void> {
// 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;
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -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:';
Expand Down
3 changes: 0 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 0 additions & 17 deletions src/tree/treeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ export class TreeProvider implements vscode.TreeDataProvider<vscode.TreeItem> {

//#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 {
Expand Down Expand Up @@ -143,7 +141,6 @@ export class TreeProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
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);
Expand Down Expand Up @@ -189,20 +186,6 @@ export class TreeProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
}
}

// private getConnectedItems(item: vscode.TreeItem): vscode.TreeItem[] {
// if (item instanceof TreeItemFile) {
// const file = <TreeItemFile>item;
// return this.tokens.filter(it => it.file === file);
// } else if (item instanceof TreeItemToken) {
// const token = <TreeItemToken>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<vscode.TreeItem> {
return <vscode.TreeItem>element;
}
Expand Down

0 comments on commit 356863d

Please sign in to comment.