-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce codespell and example linters (#1)
Set up `codespell`, a simple spelling linter, and `example`, a wholly custom linter which is defined 100% in the plugins repo.
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import sys | ||
|
||
def to_result_sarif(path: str, line_number: int, column_number: int, rule_id: str, message: str): | ||
return { | ||
"level": "error", | ||
"locations": [{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": path, | ||
}, | ||
"region": { | ||
"startColumn": column_number, | ||
"startLine": line_number, | ||
} | ||
} | ||
}], | ||
"message": { | ||
"text": message, | ||
}, | ||
"ruleId": rule_id, | ||
} | ||
|
||
# the engrish langauge is easy to mispell | ||
|
||
def main(argv): | ||
|
||
results = [] | ||
|
||
for line in sys.stdin.readlines(): | ||
filename, line_number, message = line.split(':') | ||
results.append(to_result_sarif(filename, int(line_number), 0, 'misspelled', message.strip())) | ||
|
||
|
||
sarif = { | ||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", | ||
"version": "2.1.0", | ||
"runs": [{ | ||
"results": results | ||
}], | ||
} | ||
|
||
print(json.dumps(sarif, indent=2)) | ||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
LINE_NUMBER=0 | ||
COLUMN_NUMBER=0 | ||
SEVERITY="error" | ||
MESSAGE="example message" | ||
CODE="example-finding" | ||
|
||
for PATH in "${BASH_ARGV[@]}" | ||
do | ||
echo "${PATH}:${LINE_NUMBER}:${COLUMN_NUMBER}: [${SEVERITY}] ${MESSAGE} (${CODE})" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters