Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GixyBear.py: Add GixyBear #2754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions bears/configfiles/GixyBear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json

from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.PipRequirement import PipRequirement
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
from coalib.results.Result import Result


@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)
25 changes: 25 additions & 0 deletions tests/configfiles/GixyBearTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

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, ))