Skip to content

Commit

Permalink
workaround JS bug returning incorrect conditional on YAML error
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Jul 12, 2024
1 parent 83e78e1 commit 5d0f2d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### 1.3.2 (Next)
- Improve YAML syntax error message parsing.
- Ignore irrelevant inventory and hosts warnings.
- Workaround JS bug returning incorrect conditional on YAML error.

bug in pulsar/ide-ui causing issues displaying yaml syntax message
warnings no longer captured randomly
update error-line-col, bad_include, missing_include because syntax-check no longer finding errors in general
diagnostic missing message for temp fixture copied here
task with only name emits uncaptured message
js bug causes matchesYAMLError[1] message to not be captured (yaml_syntax fixture)

### 1.3.1
- Updates to Linter API usage.
Expand Down
7 changes: 3 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,16 @@ export default {
const matchesRange = /line\s(\d+),\scolumn\s(\d+)/.exec(output);
let theRange = [[0, 0], [0, 1]];

// if this is a yaml syntax error, then replace the ansible error message with the yaml syntax error
let excerpt = matchesYAMLError == null ? matchesError[1] : matchesYAMLError[1];

// parse range
if (matchesRange != null) {
theRange = [[Number.parseInt(matchesRange[1], 10) - 1, Number.parseInt(matchesRange[2], 10) - 1], [Number.parseInt(matchesRange[1], 10) - 1, Number.parseInt(matchesRange[2], 10)]];
}

toReturn.push({
severity: 'error',
excerpt,
// if this is a yaml syntax error, then replace the ansible error message with the yaml syntax error
// there is a bizarre js bug occurring here due to obsolete node.js, and so null is checked on the first matcher instead
excerpt: matchesYAMLError[1] == null ? matchesError[1] : matchesYAMLError[1],
location: {
file: theFile,
position: theRange,
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"linter",
"ansible"
],
"scripts": {
"test": "pulsar --test spec"
},
"bugs": {
"url": "https://github.com/mschuchard/linter-ansible-syntax/issues"
},
"engines": {
"atom": ">0.95.0"
"pulsar": ">=1.0.0"
},
"providedServices": {
"linter": {
Expand All @@ -39,7 +42,7 @@
"error",
{
"ignore": [
"atom"
"pulsar"
]
}
]
Expand All @@ -49,7 +52,7 @@
"node": true
},
"globals": {
"atom": false
"pulsar": false
}
}
}

0 comments on commit 5d0f2d4

Please sign in to comment.