Skip to content

Commit

Permalink
Add LANGUAGES property to bears
Browse files Browse the repository at this point in the history
  • Loading branch information
attila0x2A committed Apr 28, 2016
1 parent 41491ec commit bf714a6
Show file tree
Hide file tree
Showing 43 changed files with 47 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bears/c_languages/ClangBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def clang_available(cls):


class ClangBear(LocalBear):
LANGUAGES = 'C', 'C++', 'Objective C', 'Objective C++'
LANGUAGES = ("C", "C++", "Objective-C", "Objective-C++", "OpenMP",
"OpenCL", "CUDA")

check_prerequisites = classmethod(clang_available)

Expand Down
3 changes: 2 additions & 1 deletion bears/c_languages/codeclone_detection/ClangASTPrintBear.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from clang.cindex import Index, TranslationUnit

from bears.c_languages.ClangBear import clang_available
from bears.c_languages.ClangBear import clang_available, ClangBear
from coalib.bears.GlobalBear import GlobalBear


class ClangASTPrintBear(GlobalBear):
check_prerequisites = classmethod(clang_available)
LANGUAGES = ClangBear.LANGUAGES

def print_node(self, cursor, filename, before="", spec_before=""):
'''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from bears.c_languages.ClangBear import clang_available
from bears.c_languages.ClangBear import clang_available, ClangBear
from bears.c_languages.codeclone_detection.ClangFunctionDifferenceBear import (
ClangFunctionDifferenceBear)
from coalib.bears.GlobalBear import GlobalBear
Expand All @@ -8,6 +8,7 @@

class ClangCloneDetectionBear(GlobalBear):
check_prerequisites = classmethod(clang_available)
LANGUAGES = ClangBear.LANGUAGES

def run(self,
dependency_results: dict,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import functools
from itertools import combinations

from bears.c_languages.ClangBear import clang_available
from bears.c_languages.ClangBear import clang_available, ClangBear
from bears.c_languages.codeclone_detection.ClangCountingConditions import (
condition_dict)
from bears.c_languages.codeclone_detection.ClangCountVectorCreator import (
Expand Down Expand Up @@ -82,6 +82,7 @@ def get_difference(function_pair,

class ClangFunctionDifferenceBear(GlobalBear):
check_prerequisites = classmethod(clang_available)
LANGUAGES = ClangBear.LANGUAGES

def run(self,
counting_conditions: counting_condition_dict=default_cc_dict,
Expand Down
1 change: 1 addition & 0 deletions bears/cmake/CMakeLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class CMakeLintBear:
"""
Checks the code with ``cmakelint``.
"""
LANGUAGES = 'CMake'

@staticmethod
def create_arguments(filename, file, config_file,
Expand Down
1 change: 1 addition & 0 deletions bears/configfiles/DockerfileLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DockerfileLintBear:
See <https://github.com/projectatomic/dockerfile_lint#dockerfile-lint> for
more information .
"""
LANGUAGES = "Dockerfile"

severity_map = {
"error": RESULT_SEVERITY.MAJOR,
Expand Down
1 change: 1 addition & 0 deletions bears/css/CSSAutoPrefixBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class CSSAutoPrefixBear(Lint, LocalBear):
prerequisite_fail_msg = "Autoprefixer is not installed."
diff_message = "Add vendor prefixes to CSS rules."
gives_corrected = True
LANGUAGES = "CSS"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/dart/DartLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DartLintBear(LocalBear, Lint):
severity_map = {
"error": RESULT_SEVERITY.MAJOR,
"warning": RESULT_SEVERITY.NORMAL}
LANGUAGES = "Dart"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/general/InvalidLinkBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class InvalidLinkBear(LocalBear):
DEFAULT_TIMEOUT = 2
LANGUAGES = "All"

@classmethod
def check_prerequisites(cls):
Expand Down
1 change: 1 addition & 0 deletions bears/general/KeywordBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


class KeywordBear(LocalBear):
LANGUAGES = "All"

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/general/LineCountBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class LineCountBear(LocalBear):
LANGUAGES = "All"

def run(self, filename, file, max_lines_per_file: int):
"""
Expand Down
1 change: 1 addition & 0 deletions bears/general/LineLengthBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class LineLengthBear(LocalBear):
LANGUAGES = "All"

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/general/SpaceConsistencyBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class SpaceConsistencyBear(LocalBear):
LANGUAGES = "All"

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/go/GoImportsBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class GoImportsBear(Lint, LocalBear):
diff_message = "Imports need to be added/removed."
use_stdin = True
gives_corrected = True
LANGUAGES = "Go"

def run(self, filename, file):
"""
Expand Down
1 change: 1 addition & 0 deletions bears/go/GoLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class GoLintBear(LocalBear, Lint):
output_regex = re.compile(
r'(?P<path>.*?)\:(?P<line>\d+)\:(?P<column>\d+)\: (?P<message>.*)')
use_stdout = True
LANGUAGES = "Go"

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/go/GoReturnsBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class GoReturnsBear(Lint, LocalBear):
diff_message = "Imports or returns need to be added/removed."
use_stdin = True
gives_corrected = True
LANGUAGES = "Go"

def run(self, filename, file):
"""
Expand Down
1 change: 1 addition & 0 deletions bears/go/GoTypeBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class GoTypeBear(LocalBear, Lint):
use_stderr = True
output_regex = re.compile(
r'(?P<file_name>.*):(?P<line>\d+):(?P<column>\d+):\s*(?P<message>.*)')
LANGUAGES = "Go"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/go/GoVetBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class GoVetBear:
This is done using the ``vet`` command. For more information visit
<https://golang.org/cmd/vet/>.
"""
LANGUAGES = "Go"

@staticmethod
def create_arguments(filename, file, config_file):
Expand Down
1 change: 1 addition & 0 deletions bears/go/GofmtBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class GofmtBear:
This is done using the ``gofmt`` utility. For more information visit
<https://golang.org/cmd/gofmt/>.
"""
LANGUAGES = "Go"

@staticmethod
def create_arguments(filename, file, config_file):
Expand Down
1 change: 1 addition & 0 deletions bears/hypertext/BootLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BootLintBear:
For more about the analysis, check Bootlint
<https://github.com/twbs/bootlint#bootlint>.
"""
LANGUAGES = "HTML"

@staticmethod
def create_arguments(filename, file, config_file,
Expand Down
1 change: 1 addition & 0 deletions bears/java/InferBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class InferBear(LocalBear, Lint):
severity_map = {
"error": RESULT_SEVERITY.MAJOR,
"warning": RESULT_SEVERITY.NORMAL}
LANGUAGES = "Java"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/js/JSComplexityBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class JSComplexityBear(LocalBear, Lint):
executable = "cr"
LANGUAGES = "Javascript"

def process_output(self, output, filename, file):
message = "{} has a cyclomatic complexity of {}."
Expand Down
1 change: 1 addition & 0 deletions bears/js/JSONFormatBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class JSONFormatBear(Lint, LocalBear):
diff_message = ("This file can be reformatted by sorting keys and "
"following indentation.")
gives_corrected = True
LANGUAGES = "JSON"

def lint(self, filename, file, **kwargs):
try:
Expand Down
1 change: 1 addition & 0 deletions bears/julia/JuliaLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class JuliaLintBear:
See <https://lintjl.readthedocs.org/en/stable/> for more information
on the analysis provided.
"""
LANGUAGES = "Julia"

@staticmethod
def create_arguments(filename, file, config_file):
Expand Down
1 change: 1 addition & 0 deletions bears/latex/LatexLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LatexLintBear(LocalBear, Lint):
severity_map = {'Warning': RESULT_SEVERITY.NORMAL,
'Error': RESULT_SEVERITY.MAJOR}
arguments = "{filename}"
LANGUAGES = "Tex"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/matlab/MatlabIndentationBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class MatlabIndentationBear(LocalBear):
LANGUAGES = ("Matlab", "Octave")

def run(self, filename, file, tab_width: int=2):
"""
Expand Down
1 change: 1 addition & 0 deletions bears/natural_language/AlexBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class AlexBear(LocalBear, Lint):
r'(?P<end_line>\d+):(?P<end_column>\d+)'
r'\s+(?:(?P<warning>warning))\s+(?P<message>.+)')
arguments = "{filename}"
LANGUAGES = "Natural Language"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/natural_language/LanguageToolBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class LanguageToolBear(LocalBear):
LANGUAGES = "Natural Language"

@classmethod
def check_prerequisites(cls):
Expand Down
1 change: 1 addition & 0 deletions bears/natural_language/ProseLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ProseLintBear(LocalBear, Lint):
output_regex = re.compile(
r'.+?:(?P<line>\d+):(?P<column>\d+): (?P<code>\S*) (?P<message>.+)')
arguments = "{filename}"
LANGUAGES = "Natural Language"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/perl/PerlCriticBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PerlCriticBear(LocalBear, Lint):
"3": RESULT_SEVERITY.NORMAL,
"4": RESULT_SEVERITY.NORMAL,
"5": RESULT_SEVERITY.INFO}
LANGUAGES = "Perl"

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/php/PHPLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PHPLintBear(LocalBear, Lint):
severity_map = {
"Parse": RESULT_SEVERITY.MAJOR,
"Fatal": RESULT_SEVERITY.MAJOR}
LANGUAGES = "PHP"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/python/PEP8Bear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class PEP8Bear(Lint, LocalBear):
diff_message = "The code does not comply to PEP8."
gives_corrected = True
LANGUAGES = ("Python", "Python 2", "Python 3")

def lint(self, filename, file, apply_config, **kwargs):
new_file = autopep8.fix_code(''.join(file), options=kwargs,
Expand Down
1 change: 1 addition & 0 deletions bears/python/PyCommentedCodeBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class PyCommentedCodeBear(Lint, LocalBear):
gives_corrected = True
diff_message = "This file contains commented out source code."
LANGUAGES = ("Python", "Python 2", "Python 3")

def lint(self, filename, file):
output = list(eradicate.filter_commented_out_code(''.join(file)))
Expand Down
1 change: 1 addition & 0 deletions bears/python/PyDocStyleBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PyDocStyleBear(LocalBear, Lint):
executable = 'pydocstyle'
output_regex = r'(.*\.py):(?P<line>\d+) (.+):\n\s+(?P<message>.*)'
use_stderr = True
LANGUAGES = ("Python", "Python 2", "Python 3")

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/python/PyLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PyLintBear(LocalBear, Lint):
"C": RESULT_SEVERITY.INFO,
"R": RESULT_SEVERITY.INFO,
"I": RESULT_SEVERITY.INFO}
LANGUAGES = ("Python", "Python 2", "Python 3")

def run(self,
filename,
Expand Down
1 change: 1 addition & 0 deletions bears/python/PyUnusedCodeBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class PyUnusedCodeBear(Lint, LocalBear):
diff_message = "This file contains unused source code."
gives_corrected = True
LANGUAGES = ("Python", "Python 2", "Python 3")

def lint(self, filename, file):
output = autoflake.fix_code(''.join(file)).splitlines(True)
Expand Down
1 change: 1 addition & 0 deletions bears/python/RadonBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


class RadonBear(LocalBear):
LANGUAGES = ("Python", "Python 2", "Python 3")

def run(self, filename, file,
radon_ranks_info: typed_list(str)=(),
Expand Down
1 change: 1 addition & 0 deletions bears/r/FormatRBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class FormatRBear(Lint, LocalBear):
prerequisite_fail_msg = "Please install formatR for this bear to work."
diff_message = "Formatting can be improved."
gives_corrected = True
LANGUAGES = "R"

def process_output(self, output, filename, file):
output = output[:-1] + (output[-1].strip()+"\n",)
Expand Down
1 change: 1 addition & 0 deletions bears/r/RLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RLintBear(LocalBear, Lint):
"style": RESULT_SEVERITY.NORMAL,
"warning": RESULT_SEVERITY.NORMAL,
"error": RESULT_SEVERITY.MAJOR}
LANGUAGES = "R"

prerequisite_command = ["Rscript", "-e", "library(lintr)"]
prerequisite_fail_msg = 'R library "lintr" is not installed.'
Expand Down
1 change: 1 addition & 0 deletions bears/rest/reSTLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


class reSTLintBear(LocalBear):
LANGUAGES = "reStructuredText"

def run(self, filename, file):
"""
Expand Down
1 change: 1 addition & 0 deletions bears/ruby/RubySyntaxBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RubySyntaxBear(LocalBear, Lint):
severity_map = {
"warning": RESULT_SEVERITY.NORMAL,
"error": RESULT_SEVERITY.MAJOR}
LANGUAGES = "Ruby"

def run(self, filename, file):
'''
Expand Down
1 change: 1 addition & 0 deletions bears/vcs/git/GitCommitBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class GitCommitBear(GlobalBear):
LANGUAGES = "Git"

@classmethod
def check_prerequisites(cls):
Expand Down
1 change: 1 addition & 0 deletions bears/xml/XMLBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class XMLBear(LocalBear, Lint):
output_regex = r'(.*\.xml):(?P<line>\d+): (?P<message>.*)\n.*\n.*'
gives_corrected = True
use_stderr = True
LANGUAGES = "XML"

def process_output(self, output, filename, file):
if self.stdout_output:
Expand Down

0 comments on commit bf714a6

Please sign in to comment.