-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bears/dart: Add bear for Dart using Dart Linter
Add a bear for Dart, which is a scalable programming language. It looks a bit like a python or javascript. Fixes #105
- Loading branch information
1 parent
8430f31
commit 93b3d8f
Showing
6 changed files
with
64 additions
and
0 deletions.
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
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,26 @@ | ||
import re | ||
|
||
from coalib.bearlib.abstractions.Lint import Lint | ||
from coalib.bears.LocalBear import LocalBear | ||
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY | ||
|
||
|
||
class DartLintBear(LocalBear, Lint): | ||
executable = 'dartanalyzer' | ||
output_regex = re.compile( | ||
r'\[(?P<severity>error|warning)\] (?P<message>.+)\(' | ||
r'(?P<file_name>.+), line (?P<line>\d+),' | ||
r' col (?P<column>\d+)\)') | ||
severity_map = { | ||
"error": RESULT_SEVERITY.MAJOR, | ||
"warning": RESULT_SEVERITY.NORMAL} | ||
|
||
def run(self, filename, file): | ||
''' | ||
Checks the code with ``dart-linter``. | ||
This bear expects dart commands to be on your ``PATH``. Please ensure | ||
/path/to/dart-sdk/bin is in your ``PATH``. | ||
''' | ||
self.arguments = '{filename}' | ||
return self.lint(filename) |
Empty file.
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
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,32 @@ | ||
from bears.dart.DartLintBear import DartLintBear | ||
from tests.LocalBearTestHelper import verify_local_bear | ||
|
||
|
||
good_file = """ | ||
printNumber(num aNumber) { | ||
print('The number is $aNumber.'); | ||
} | ||
main() { | ||
var answer = 42; // The meaning of life. | ||
printNumber(answer); | ||
} | ||
""".splitlines(keepends=True) | ||
|
||
|
||
bad_file = """ | ||
printNumber(num aNumber) { | ||
print('The number is $aNumber.') | ||
} | ||
main() { | ||
var answer = 42; // The meaning of life. | ||
printNumber(answer) | ||
} | ||
""".splitlines(keepends=True) | ||
|
||
|
||
DartLintBearTest = verify_local_bear(DartLintBear, | ||
valid_files=(good_file,), | ||
invalid_files=(bad_file,), | ||
tempfile_kwargs={"suffix": ".dart"}) |
Empty file.