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

Add extension setting to toggle undefined variable warning for global variables #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
"default": true,
"description": "Process and display sqflint warnings."
},
"sqflint.globalVarWarnings": {
"type": "boolean",
"default": false,
"description": "Show 'Possibly undefined variable' warnings for global variables. (NOTE! Restart your Visual Studio Code after changing this setting!)"
}
,
"sqflint.indexWorkspace": {
"type": "boolean",
"default": true,
Expand Down
5 changes: 4 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface Settings {
*/
export interface SQFLintSettings {
warnings: boolean;
globalVarWarnings: boolean,
indexWorkspace: boolean;
indexWorkspaceTwice: boolean;
checkPaths: boolean;
Expand Down Expand Up @@ -252,6 +253,7 @@ export class SQFLintServer {

this.settings = {
warnings: true,
globalVarWarnings: false,
indexWorkspace: true,
indexWorkspaceTwice: true,
exclude: [],
Expand All @@ -277,6 +279,7 @@ export class SQFLintServer {
this.settings.indexWorkspace = settings.sqflint.indexWorkspace;
this.settings.indexWorkspaceTwice = settings.sqflint.indexWorkspaceTwice;
this.settings.warnings = settings.sqflint.warnings;
this.settings.globalVarWarnings = settings.sqflint.globalVarWarnings;
this.settings.exclude = settings.sqflint.exclude;
this.settings.ignoredVariables = settings.sqflint.ignoredVariables;
this.settings.includePrefixes = settings.sqflint.includePrefixes;
Expand Down Expand Up @@ -802,7 +805,7 @@ export class SQFLintServer {
}

// Add warning if global variable wasn't defined.
if (!defined && this.settings.warnings && !this.ignoredVariablesSet[item.ident]) {
if (!defined && this.settings.warnings && !this.ignoredVariablesSet[item.ident] && this.settings.globalVarWarnings) {
for (const u in item.usage) {
diagnostics.push({
severity: DiagnosticSeverity.Warning,
Expand Down