Skip to content

Commit

Permalink
Use QuotesBear on all code
Browse files Browse the repository at this point in the history
Due to a bug it will replace multiline strings in one line with:
'"" string ""'.

I had to manually postcorrect those to single line strings.
  • Loading branch information
sils committed Nov 22, 2016
1 parent 0898447 commit 28d24b6
Show file tree
Hide file tree
Showing 173 changed files with 1,644 additions and 1,644 deletions.
8 changes: 4 additions & 4 deletions .coafile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use_spaces = True
# will be executed sequentially; also we need the LineLengthBear to double
# check the line length because PEP8Bear sometimes isn't able to correct the
# linelength.
bears = SpaceConsistencyBear
default_actions =
SpaceConsistencyBear: ApplyPatchAction,
PyUnusedCodeBear: ApplyPatchAction
bears = SpaceConsistencyBear, QuotesBear
language = python
default_actions = *: ApplyPatchAction
preferred_quotation = '

[autopep8]
bears = PEP8Bear
Expand Down
4 changes: 2 additions & 2 deletions bears/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys


VERSION_FILE = os.path.join(os.path.dirname(__file__), "VERSION")
VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
with open(VERSION_FILE, 'r') as ver:
VERSION = ver.readline().strip()

Expand All @@ -18,5 +18,5 @@

def assert_supported_version(): # pragma: no cover
if not sys.version_info > (3, 3):
print("coala supports only python 3.4 or later.")
print('coala supports only python 3.4 or later.')
exit(4)
16 changes: 8 additions & 8 deletions bears/c_languages/CPPCheckBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
from coalib.settings.Setting import typed_list


@linter(executable="cppcheck",
@linter(executable='cppcheck',
use_stdout=False,
use_stderr=True,
output_format="regex",
output_format='regex',
output_regex=r'(?P<line>\d+):(?P<severity>[a-zA-Z]+):'
r'(?P<origin>[a-zA-Z]+):(?P<message>.*)',
severity_map={"error": RESULT_SEVERITY.MAJOR,
"warning": RESULT_SEVERITY.NORMAL,
"style": RESULT_SEVERITY.INFO})
severity_map={'error': RESULT_SEVERITY.MAJOR,
'warning': RESULT_SEVERITY.NORMAL,
'style': RESULT_SEVERITY.INFO})
class CPPCheckBear:
"""
Report possible security weaknesses for C/C++.
For more information, consult <https://github.com/danmar/cppcheck>.
"""

LANGUAGES = {"C", "C++"}
LANGUAGES = {'C', 'C++'}
REQUIREMENTS = {DistributionRequirement(apt_get='cppcheck')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand All @@ -37,9 +37,9 @@ def create_arguments(filename, file, config_file,
portability, information, unusedFunction,
missingInclude
"""
args = ("--template={line}:{severity}:{id}:{message}",)
args = ('--template={line}:{severity}:{id}:{message}',)

if enable:
args += ('--enable=' + ",".join(enable),)
args += ('--enable=' + ','.join(enable),)

return args + (filename,)
2 changes: 1 addition & 1 deletion bears/c_languages/CPPCleanBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CPPCleanBear:
<https://github.com/myint/cppclean#features>.
"""

LANGUAGES = {"C++"}
LANGUAGES = {'C++'}
REQUIREMENTS = {PipRequirement('cppclean', '0.9.*')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand Down
2 changes: 1 addition & 1 deletion bears/c_languages/CPPLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CPPLintBear:
For more information, consult <https://github.com/theandrewdavis/cpplint>.
"""

LANGUAGES = {"C++"}
LANGUAGES = {'C++'}
REQUIREMENTS = {PipRequirement('cpplint', '1.*')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand Down
16 changes: 8 additions & 8 deletions bears/c_languages/CSecurityBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY


@linter(executable="flawfinder",
output_format="regex",
@linter(executable='flawfinder',
output_format='regex',
output_regex=r'.+:(?P<line>\d+):(?P<column>\d+):\s*'
r'\[(?P<severity>\d)\]\s*'
r'\((?P<origin>.+)\) (?P<message>.+)',
severity_map={"1": RESULT_SEVERITY.INFO,
"2": RESULT_SEVERITY.INFO,
"3": RESULT_SEVERITY.NORMAL,
"4": RESULT_SEVERITY.NORMAL,
"5": RESULT_SEVERITY.MAJOR},
severity_map={'1': RESULT_SEVERITY.INFO,
'2': RESULT_SEVERITY.INFO,
'3': RESULT_SEVERITY.NORMAL,
'4': RESULT_SEVERITY.NORMAL,
'5': RESULT_SEVERITY.MAJOR},
prerequisite_check_command=('flawfinder',),
prerequisite_check_fail_message=('Flawfinder needs to be run with '
'python2.'))
Expand All @@ -34,4 +34,4 @@ class CSecurityBear:

@staticmethod
def create_arguments(filename, file, config_file):
return "--columns", "--dataonly", "--quiet", "--singleline", filename
return '--columns', '--dataonly', '--quiet', '--singleline', filename
2 changes: 1 addition & 1 deletion bears/c_languages/CSharpLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CSharpLintBear:
Checks C# code for syntactical correctness using the ``mcs`` compiler.
"""

LANGUAGES = {"C#"}
LANGUAGES = {'C#'}
REQUIREMENTS = {DistributionRequirement(apt_get='mono-mcs')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand Down
4 changes: 2 additions & 2 deletions bears/c_languages/ClangBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def clang_available(cls):


class ClangBear(LocalBear):
LANGUAGES = {"C", "C++", "Objective-C", "Objective-C++", "OpenMP",
"OpenCL", "CUDA"}
LANGUAGES = {'C', 'C++', 'Objective-C', 'Objective-C++', 'OpenMP',
'OpenCL', 'CUDA'}
REQUIREMENTS = {PipRequirement('libclang-py3', '0.2')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand Down
22 changes: 11 additions & 11 deletions bears/c_languages/ClangComplexityBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ def run(self, filename, file, cyclomatic_complexity: int=8):
yield Result(
self,
"The function '{function}' should be simplified. Its "
"cyclomatic complexity is {complexity} which exceeds "
"maximal recommended value "
"of {rec_value}.".format(
'cyclomatic complexity is {complexity} which exceeds '
'maximal recommended value '
'of {rec_value}.'.format(
function=cursor.displayname,
complexity=complexity,
rec_value=cyclomatic_complexity),
affected_code=affected_code,
additional_info=(
"The cyclomatic complexity is a metric that measures "
"how complicated a function is by counting branches "
"and exits of each function.\n\n"
"Your function seems to be complicated and should be "
"refactored so that it can be understood by other "
"people easily.\n\nSee "
"<http://www.wikiwand.com/en/Cyclomatic_complexity>"
" for more information."))
'The cyclomatic complexity is a metric that measures '
'how complicated a function is by counting branches '
'and exits of each function.\n\n'
'Your function seems to be complicated and should be '
'refactored so that it can be understood by other '
'people easily.\n\nSee '
'<http://www.wikiwand.com/en/Cyclomatic_complexity>'
' for more information.'))
58 changes: 29 additions & 29 deletions bears/c_languages/GNUIndentBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
DistributionRequirement)


@linter(executable="indent" if platform.system() != "Darwin" else "gindent",
@linter(executable='indent' if platform.system() != 'Darwin' else 'gindent',
use_stdin=True,
output_format='corrected',
result_message="Indentation can be improved.")
result_message='Indentation can be improved.')
class GNUIndentBear:
"""
This bear checks and corrects spacing and indentation via the well known
Expand All @@ -20,7 +20,7 @@ class GNUIndentBear:
C++ support is considered experimental.
"""

LANGUAGES = {"C", "C++"}
LANGUAGES = {'C', 'C++'}
REQUIREMENTS = {DistributionRequirement(apt_get='indent')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
Expand Down Expand Up @@ -160,39 +160,39 @@ def create_arguments(filename, file, config_file,
Any command line options the indent binary understands. They
will be simply passed through.
"""
indent_options = ("--no-tabs" if use_spaces else "--use-tabs",
"--line-length", str(max_line_length),
"--indent-level", str(indent_size),
"--tab-size", str(indent_size), )
indent_options += (("--cuddle-do-while",)
indent_options = ('--no-tabs' if use_spaces else '--use-tabs',
'--line-length', str(max_line_length),
'--indent-level', str(indent_size),
'--tab-size', str(indent_size), )
indent_options += (('--cuddle-do-while',)
if while_and_brace_on_same_line
else ("--dont-cuddle-do-while",))
indent_options += (("--swallow-optional-blank-lines",)
if delete_optional_blank_lines else ("-nsob",))
indent_options += (("--blank-lines-after-declarations",)
if blank_lines_after_declarations else ("-nbad",))
indent_options += (("--blank-lines-after-commas",)
if blank_lines_after_commas else ("-nbc",))
indent_options += (("--blank-lines-after-procedures",)
if blank_lines_after_procedures else ("-nbap",))
indent_options += (("-di" + str(declaration_indent),)
else ('--dont-cuddle-do-while',))
indent_options += (('--swallow-optional-blank-lines',)
if delete_optional_blank_lines else ('-nsob',))
indent_options += (('--blank-lines-after-declarations',)
if blank_lines_after_declarations else ('-nbad',))
indent_options += (('--blank-lines-after-commas',)
if blank_lines_after_commas else ('-nbc',))
indent_options += (('--blank-lines-after-procedures',)
if blank_lines_after_procedures else ('-nbap',))
indent_options += (('-di' + str(declaration_indent),)
if declaration_indent != 0 else ())
indent_options += (("--case-indentation"+str(case_indentation),)
indent_options += (('--case-indentation'+str(case_indentation),)
if case_indentation != 0 else ())
indent_options += (("--space-special-semicolon",)
indent_options += (('--space-special-semicolon',)
if space_before_semicolon_after_empty_loop
else ("-nss",))
indent_options += ("--brace-indent"+str(brace_indent),)
indent_options += (("--braces-on-func-def-line",)
if braces_on_func_def_line else ("-blf",))
indent_options += ((("-ce",) if cuddle_else else ("-nce",)) +
("-br",)) if braces_on_if_line else ("-bl",)
else ('-nss',))
indent_options += ('--brace-indent'+str(brace_indent),)
indent_options += (('--braces-on-func-def-line',)
if braces_on_func_def_line else ('-blf',))
indent_options += ((('-ce',) if cuddle_else else ('-nce',)) +
('-br',)) if braces_on_if_line else ('-bl',)
indent_style_option = ()
indent_style_option += ("--gnu-style",) if gnu_style else ()
indent_style_option += (("--k-and-r-style",)
indent_style_option += ('--gnu-style',) if gnu_style else ()
indent_style_option += (('--k-and-r-style',)
if k_and_r_style and indent_style_option is ()
else ())
indent_style_option += (("--linux-style",)
indent_style_option += (('--linux-style',)
if linux_style and indent_style_option is ()
else ())
# If a style is chosen the other configs aren't passed to `indent`
Expand Down
18 changes: 9 additions & 9 deletions bears/c_languages/codeclone_detection/ClangASTPrintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ClangASTPrintBear(GlobalBear):
LANGUAGES = ClangBear.LANGUAGES
REQUIREMENTS = ClangBear.REQUIREMENTS

def print_node(self, cursor, filename, before="", spec_before=""):
def print_node(self, cursor, filename, before='', spec_before=''):
'''
Prints this node and all child nodes recursively in the style of:
Expand All @@ -30,26 +30,26 @@ def print_node(self, cursor, filename, before="", spec_before=""):

if file is not None and file.name == filename:
self.debug(
before + spec_before + "-" + str(cursor.displayname),
before + spec_before + '-' + str(cursor.displayname),
str(cursor.kind),
"Lines",
str(cursor.extent.start.line) + "-" +
'Lines',
str(cursor.extent.start.line) + '-' +
str(cursor.extent.end.line),
"(" + " ".join(str(token.spelling)
for token in cursor.get_tokens()) + ")")
'(' + ' '.join(str(token.spelling)
for token in cursor.get_tokens()) + ')')

children = list(cursor.get_children())

if len(children) > 0:
for child in children[:-1]:
self.print_node(child,
filename,
before + len(spec_before)*" " + "|")
before + len(spec_before)*' ' + '|')

self.print_node(children[-1],
filename,
before + len(spec_before)*" ",
"`")
before + len(spec_before)*' ',
'`')

def run(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def run(self,
count_matrices = dependency_results[
ClangFunctionDifferenceBear.__name__][1].contents

self.debug("Creating results...")
self.debug('Creating results...')
for function_1, function_2, difference in differences:
if difference < max_clone_difference:
yield Result.from_values(
self,
"Code clone found. The other occurrence is at file "
"{file}, line {line}, function {function}. The "
"difference is {difference}%.".format(
'Code clone found. The other occurrence is at file '
'{file}, line {line}, function {function}. The '
'difference is {difference}%.'.format(
file=function_2[0],
line=function_2[1],
function=function_2[2],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_vectors_for_file(self, filename, include_paths=()):
:return: The dictionary holding CountVectors for all variables
in all functions.
"""
args = ["-I"+path for path in include_paths]
args = ['-I'+path for path in include_paths]
root = Index.create().parse(filename, args=args).cursor

return self._get_vectors_for_cursor(root, filename)
Loading

0 comments on commit 28d24b6

Please sign in to comment.