forked from coala/coala-bears
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds GixyBear. Closes coala#1724
- Loading branch information
1 parent
dc8c95c
commit 8486e03
Showing
2 changed files
with
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from coalib.bearlib.abstractions.Linter import linter | ||
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY | ||
from coalib.results.Result import Result | ||
import json | ||
|
||
|
||
@linter(executable='gixy') | ||
class GixyBear: | ||
""" | ||
A wrapper for coala around Gixy | ||
see <https://github.com/yandex/gixy> for more information about the tool | ||
""" | ||
REQUIREMENTS={PipRequirement('gixy', '0.1.*')} | ||
|
||
severity_map = {'HIGH': RESULT_SEVERITY.MAJOR, | ||
'MEDIUM': RESULT_SEVERITY.NORMAL, | ||
'LOW': RESULT_SEVERITY.INFO} | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file): | ||
return ('--format=json', filename) | ||
|
||
def process_output(self, output, filename, file): | ||
output = json.loads(output) if output else [] | ||
for issue in output: | ||
yield Result.from_values(origin=self, | ||
message=issue['summary'], | ||
severity=self.severity_map[issue['severity']], | ||
file=filename) |
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 os | ||
|
||
from bears.configfiles.GixyBear import GixyBear | ||
from coalib.testing.LocalBearTestHelper import verify_local_bear | ||
|
||
good_file = """ | ||
server { | ||
location ~ \.(gif|jpg|png)$ { | ||
root /data/images; | ||
} | ||
} | ||
""" | ||
|
||
bad_file = """ | ||
http{ | ||
server{ | ||
location ~ /proxy/(.*)/(.*)/(.*)$ { | ||
proxy_pass $1://$2/$3; | ||
} | ||
} | ||
} | ||
""" | ||
|
||
GixyBearTest = verify_local_bear(GixyBear, | ||
valid_files = (good_file, ), | ||
invalid_files = (bad_file, )) |