Skip to content

Commit

Permalink
Implement #18
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Nov 18, 2021
1 parent bde803e commit 4ce7969
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const errorText = {
'RequireBlankSpecial': `\`*BLANK\` should be used over empty string literals.`,
'CopybookDirective': `Directive does not match requirement.`,
'UppercaseDirectives': `Directives must be in uppercase.`,
'NoSQLJoins': `SQL joins are not allowed. Consider creating a view instead.`,
}

module.exports = class Linter {
Expand All @@ -49,6 +50,7 @@ module.exports = class Linter {
* RequireBlankSpecial?: boolean,
* CopybookDirective?: "copy"|"include"
* UppercaseDirectives?: boolean,
* NoSQLJoins?: boolean,
* SpecificCasing?: {operation: string, expected: string}[],
* }} rules
* @param {Cache|null} [definitions]
Expand Down Expand Up @@ -79,7 +81,12 @@ module.exports = class Linter {
/** @type {{
* range: vscode.Range,
* offset?: {position: number, length: number}
* type: "BlankStructNamesCheck"|"QualifiedCheck"|"PrototypeCheck"|"ForceOptionalParens"|"NoOCCURS"|"NoSELECTAll"|"UselessOperationCheck"|"UppercaseConstants"|"SpecificCasing"|"InvalidDeclareNumber"|"IncorrectVariableCase"|"RequiresParameter"|"RequiresProcedureDescription"|"StringLiteralDupe"|"RequireBlankSpecial"|"CopybookDirective"|"UppercaseDirectives",
* type:
* "BlankStructNamesCheck"|"QualifiedCheck"|"PrototypeCheck"|"ForceOptionalParens"|
* "NoOCCURS"|"NoSELECTAll"|"UselessOperationCheck"|"UppercaseConstants"|"SpecificCasing"|
* "InvalidDeclareNumber"|"IncorrectVariableCase"|"RequiresParameter"|
* "RequiresProcedureDescription"|"StringLiteralDupe"|"RequireBlankSpecial"|
* "CopybookDirective"|"UppercaseDirectives"|"NoSQLJoins",
* newValue?: string}[]
* } */
let errors = [];
Expand Down Expand Up @@ -347,6 +354,15 @@ module.exports = class Linter {
});
}
}

if (rules.NoSQLJoins) {
if (statement.some(part => part.value && part.value.toUpperCase() === `JOIN`)) {
errors.push({
range: new vscode.Range(statementStart, statementEnd),
type: `NoSQLJoins`
});
}
}
break;

case `IF`:
Expand Down
5 changes: 5 additions & 0 deletions src/schemas/rpglint.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"type": "boolean",
"description": "Directives must be in uppercase."
},
"NoSQLJoins": {
"$id": "#/properties/NoSQLJoins",
"type": "boolean",
"description": "JOINs in Embedded SQL are not allowed."
},
"SpecificCasing": {
"$id": "#/properties/SpecificCasing",
"type": "array",
Expand Down

0 comments on commit 4ce7969

Please sign in to comment.