Created
March 5, 2017 16:16
-
-
Save SanketDG/8c550fda18a2b6c008913f9aed24eb6a to your computer and use it in GitHub Desktop.
DocumentationStyleBear run
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
diff --git a/bears/c_languages/CPPLintBear.py b/bears/c_languages/CPPLintBear.py | |
index a944015..e9c93f4 100644 | |
--- a/bears/c_languages/CPPLintBear.py | |
+++ b/bears/c_languages/CPPLintBear.py | |
@@ -28,9 +28,12 @@ class CPPLintBear: | |
cpplint_ignore: typed_list(str)=(), | |
cpplint_include: typed_list(str)=()): | |
""" | |
- :param max_line_length: Maximum number of characters for a line. | |
- :param cpplint_ignore: List of checkers to ignore. | |
- :param cpplint_include: List of checkers to explicitly enable. | |
+ :param max_line_length: | |
+ Maximum number of characters for a line. | |
+ :param cpplint_ignore: | |
+ List of checkers to ignore. | |
+ :param cpplint_include: | |
+ List of checkers to explicitly enable. | |
""" | |
ignore = ','.join('-'+part.strip() for part in cpplint_ignore) | |
include = ','.join('+'+part.strip() for part in cpplint_include) | |
diff --git a/bears/c_languages/ClangBear.py b/bears/c_languages/ClangBear.py | |
index 69749b3..bdb5e37 100644 | |
--- a/bears/c_languages/ClangBear.py | |
+++ b/bears/c_languages/ClangBear.py | |
@@ -13,7 +13,8 @@ def clang_available(cls): | |
""" | |
Checks if Clang is available and ready to use. | |
- :return: True if Clang is available, a description of the error else. | |
+ :return: | |
+ True if Clang is available, a description of the error else. | |
""" | |
try: | |
Index.create() | |
@@ -40,8 +41,9 @@ class ClangBear(LocalBear): | |
This bear supports automatic fixes. | |
- :param clang_cli_options: Any options that will be passed through to | |
- Clang. | |
+ :param clang_cli_options: | |
+ Any options that will be passed through to | |
+ Clang. | |
""" | |
index = Index.create() | |
diagnostics = index.parse( | |
diff --git a/bears/c_languages/ClangComplexityBear.py b/bears/c_languages/ClangComplexityBear.py | |
index 439f1f8..b33c2d8 100644 | |
--- a/bears/c_languages/ClangComplexityBear.py | |
+++ b/bears/c_languages/ClangComplexityBear.py | |
@@ -29,8 +29,9 @@ class ClangComplexityBear(LocalBear): | |
""" | |
Calculates number of function's decision points and exit points. | |
- :param top_function_level: Whether cursor is in the top level of | |
- the function. | |
+ :param top_function_level: | |
+ Whether cursor is in the top level of | |
+ the function. | |
""" | |
decisions, exits = 0, 0 | |
@@ -84,13 +85,14 @@ class ClangComplexityBear(LocalBear): | |
You can read more about this metric at | |
<https://www.wikiwand.com/en/Cyclomatic_complexity>. | |
- :param cyclomatic_complexity: Maximum cyclomatic complexity that is | |
- considered to be normal. The value of 10 had | |
- received substantial corroborating evidence. | |
- But the general recommendation: "For each | |
- module, either limit cyclomatic complexity to | |
- [the agreed-upon limit] or provide a written | |
- explanation of why the limit was exceeded." | |
+ :param cyclomatic_complexity: | |
+ Maximum cyclomatic complexity that is | |
+ considered to be normal. The value of 10 had | |
+ received substantial corroborating evidence. | |
+ But the general recommendation: "For each | |
+ module, either limit cyclomatic complexity to | |
+ [the agreed-upon limit] or provide a written | |
+ explanation of why the limit was exceeded." | |
""" | |
root = Index.create().parse(filename).cursor | |
diff --git a/bears/c_languages/GNUIndentBear.py b/bears/c_languages/GNUIndentBear.py | |
index 63143af..e6fac3d 100644 | |
--- a/bears/c_languages/GNUIndentBear.py | |
+++ b/bears/c_languages/GNUIndentBear.py | |
@@ -58,66 +58,64 @@ class GNUIndentBear: | |
Forces blank lines after the declarations. | |
Example: | |
- If ``blank_lines_after_declarations = True`` then | |
- ``` | |
- int a; | |
- return ...; | |
- ``` | |
- changes to | |
- ``` | |
- int a; | |
- | |
- return ...; | |
- ``` | |
+ If ``blank_lines_after_declarations = True`` then | |
+ ``` | |
+ int a; | |
+ return ...; | |
+ ``` | |
+ changes to | |
+ ``` | |
+ int a; | |
+ return ...; | |
+ ``` | |
:param blank_lines_after_procedures: | |
Force blank lines after procedure bodies. | |
:param blank_lines_after_commas: | |
Forces newline after comma in declaration. | |
Example: | |
- If ``blank_lines_after_commas = True`` then | |
- ``` | |
- int a, b; | |
- ``` | |
- changes to | |
- ``` | |
- int a, | |
- b; | |
- ``` | |
+ If ``blank_lines_after_commas = True`` then | |
+ ``` | |
+ int a, b; | |
+ ``` | |
+ changes to | |
+ ``` | |
+ int a, | |
+ b; | |
+ ``` | |
:param braces_on_if_line: | |
Puts the brace ``{`` on same line with if. | |
Example: | |
- If ``braces_on_if_line = True`` then | |
- ``` | |
- if (x > 0) | |
- { | |
- ``` | |
- changes to | |
- ``` | |
- if (x > 0) { | |
- ``` | |
+ If ``braces_on_if_line = True`` then | |
+ ``` | |
+ if (x > 0) | |
+ { | |
+ ``` | |
+ changes to | |
+ ``` | |
+ if (x > 0) { | |
+ ``` | |
:param braces_on_func_def_line: | |
Puts the brace `{` on same line with the function declaration. | |
:param cuddle_else: | |
Cuddle else and preceding ``}``. | |
Example: | |
- If ``cuddle_else = True`` then | |
- ``` | |
- if (...) { | |
- .... | |
- } | |
- else { | |
- ``` | |
- changes to | |
- ``` | |
- if (...) { | |
- .... | |
- } else { | |
- ``` | |
- | |
+ If ``cuddle_else = True`` then | |
+ ``` | |
+ if (...) { | |
+ .... | |
+ } | |
+ else { | |
+ ``` | |
+ changes to | |
+ ``` | |
+ if (...) { | |
+ .... | |
+ } else { | |
+ ``` | |
:param while_and_brace_on_same_line: | |
Cuddles while of ``do {} while``; and preceding ``}``. | |
:param case_indentation: | |
@@ -127,24 +125,24 @@ class GNUIndentBear: | |
Forces a blank before the semicolon ``;`` on one-line ``for`` and | |
``while`` statements. | |
:param delete_optional_blank_lines: | |
- Deletes blank lines that are not needed. An example of needed | |
- blank line, is the blank line following a declaration when | |
- ``blank_line_after_declaration=True``. | |
+ Deletes blank lines that are not needed. An example of needed | |
+ blank line, is the blank line following a declaration when | |
+ ``blank_line_after_declaration=True``. | |
:param declaration_indent: | |
Forces variables names to be aligned in column ``n`` with | |
``n = declaration_indent`` in declaration. | |
Example: | |
- If ``declaration_indent = 8`` then, | |
- ``` | |
- int a; | |
- float b; | |
- ``` | |
- changes to | |
- ``` | |
- int a; | |
- float b; | |
- ``` | |
+ If ``declaration_indent = 8`` then, | |
+ ``` | |
+ int a; | |
+ float b; | |
+ ``` | |
+ changes to | |
+ ``` | |
+ int a; | |
+ float b; | |
+ ``` | |
:param brace_indent: | |
Specifies the number of spaces by which braces are indented. Its | |
default value is 2. | |
diff --git a/bears/c_languages/codeclone_detection/ClangCountVectorCreator.py b/bears/c_languages/codeclone_detection/ClangCountVectorCreator.py | |
index 36c8d0b..30ec3d3 100644 | |
--- a/bears/c_languages/codeclone_detection/ClangCountVectorCreator.py | |
+++ b/bears/c_languages/codeclone_detection/ClangCountVectorCreator.py | |
@@ -27,12 +27,14 @@ class ClangCountVectorCreator: | |
""" | |
Creates a new ClangCountVectorCreator. | |
- :param conditions: The counting conditions as list of function | |
- objects, each shall return true when getting | |
- data indicating that this occurrence should | |
- be counted. | |
- :param weightings: Optional factors to weight counting conditions. | |
- Defaults to 1 for all conditions. | |
+ :param conditions: | |
+ The counting conditions as list of function | |
+ objects, each shall return true when getting | |
+ data indicating that this occurrence should | |
+ be counted. | |
+ :param weightings: | |
+ Optional factors to weight counting conditions. | |
+ Defaults to 1 for all conditions. | |
""" | |
self.conditions = conditions | |
self.weightings = weightings | |
@@ -58,7 +60,8 @@ class ClangCountVectorCreator: | |
self.local_vars and in the tree elements below the given one, stores it | |
in self.count_vectors. | |
- :param cursor: Clang cursor to iterate over. | |
+ :param cursor: | |
+ Clang cursor to iterate over. | |
""" | |
assert isinstance(cursor, Cursor) | |
self.stack.append((cursor, child_num)) | |
@@ -82,10 +85,13 @@ class ClangCountVectorCreator: | |
Maps all functions in/under the given cursor to their count vectors | |
if they are defined in the given file. | |
- :param cursor: The cursor to traverse. | |
- :param filename: Absolute path to the file. | |
- :return: The dictionary holding CountVectors for all variables | |
- in all functions. | |
+ :param cursor: | |
+ The cursor to traverse. | |
+ :param filename: | |
+ Absolute path to the file. | |
+ :return: | |
+ The dictionary holding CountVectors for all variables | |
+ in all functions. | |
""" | |
assert isinstance(cursor, Cursor) | |
file = cursor.location.file | |
@@ -114,9 +120,11 @@ class ClangCountVectorCreator: | |
the function) with a CountVector object. Functions of included files | |
will not be analyzed. | |
- :param filename: The path to the file to parse. | |
- :return: The dictionary holding CountVectors for all variables | |
- in all functions. | |
+ :param filename: | |
+ The path to the file to parse. | |
+ :return: | |
+ The dictionary holding CountVectors for all variables | |
+ in all functions. | |
""" | |
args = ['-I'+path for path in include_paths] | |
root = Index.create().parse(filename, args=args).cursor | |
diff --git a/bears/c_languages/codeclone_detection/ClangCountingConditions.py b/bears/c_languages/codeclone_detection/ClangCountingConditions.py | |
index 98c1488..08b431c 100644 | |
--- a/bears/c_languages/codeclone_detection/ClangCountingConditions.py | |
+++ b/bears/c_languages/codeclone_detection/ClangCountingConditions.py | |
@@ -14,8 +14,10 @@ def is_function_declaration(cursor): | |
""" | |
Checks if the given clang cursor is a function declaration. | |
- :param cursor: A clang cursor from the AST. | |
- :return: A bool. | |
+ :param cursor: | |
+ A clang cursor from the AST. | |
+ :return: | |
+ A bool. | |
""" | |
return cursor.kind == CursorKind.FUNCTION_DECL | |
@@ -24,16 +26,20 @@ def get_identifier_name(cursor): | |
""" | |
Retrieves the identifier name from the given clang cursor. | |
- :param cursor: A clang cursor from the AST. | |
- :return: The identifier as string. | |
+ :param cursor: | |
+ A clang cursor from the AST. | |
+ :return: | |
+ The identifier as string. | |
""" | |
return cursor.displayname | |
def is_literal(cursor): | |
""" | |
- :param cursor: A clang cursor from the AST. | |
- :return: True if the cursor is a literal of any kind.. | |
+ :param cursor: | |
+ A clang cursor from the AST. | |
+ :return: | |
+ True if the cursor is a literal of any kind.. | |
""" | |
return cursor.kind in [CursorKind.INTEGER_LITERAL, | |
CursorKind.FLOATING_LITERAL, | |
@@ -50,8 +56,10 @@ def is_reference(cursor): | |
Determines if the cursor is a reference to something, i.e. an identifier | |
of a function or variable. | |
- :param cursor: A clang cursor from the AST. | |
- :return: True if the cursor is a reference. | |
+ :param cursor: | |
+ A clang cursor from the AST. | |
+ :return: | |
+ True if the cursor is a reference. | |
""" | |
return cursor.kind in [CursorKind.VAR_DECL, | |
CursorKind.PARM_DECL, | |
@@ -62,10 +70,13 @@ def _stack_contains_kind(stack, kind): | |
""" | |
Checks if a cursor with the given kind is within the stack. | |
- :param stack: The stack holding a tuple holding the parent cursors and the | |
- child number. | |
- :param kind: The kind of the cursor to search for. | |
- :return: True if the kind was found. | |
+ :param stack: | |
+ The stack holding a tuple holding the parent cursors and the | |
+ child number. | |
+ :param kind: | |
+ The kind of the cursor to search for. | |
+ :return: | |
+ True if the kind was found. | |
""" | |
for elem, _ in stack: | |
if elem.kind == kind: | |
@@ -80,11 +91,15 @@ def _is_nth_child_of_kind(stack, allowed_nums, kind): | |
stack also has a child of this element which number is in the allowed_nums | |
list. | |
- :param stack: The stack holding a tuple holding the parent cursors | |
- and the child number. | |
- :param allowed_nums: List/iterator of child numbers allowed. | |
- :param kind: The kind of the parent element. | |
- :return: Number of matches. | |
+ :param stack: | |
+ The stack holding a tuple holding the parent cursors | |
+ and the child number. | |
+ :param allowed_nums: | |
+ List/iterator of child numbers allowed. | |
+ :param kind: | |
+ The kind of the parent element. | |
+ :return: | |
+ Number of matches. | |
""" | |
is_kind_child = False | |
count = 0 | |
@@ -105,9 +120,11 @@ def is_function(stack): | |
Checks if the cursor on top of the stack is used as a method or as a | |
variable. | |
- :param stack: A stack holding a tuple holding the parent cursors and the | |
- child number. | |
- :return: True if this is used as a function, false otherwise. | |
+ :param stack: | |
+ A stack holding a tuple holding the parent cursors and the | |
+ child number. | |
+ :return: | |
+ True if this is used as a function, false otherwise. | |
""" | |
return _is_nth_child_of_kind(stack, [0], CursorKind.CALL_EXPR) != 0 | |
@@ -121,11 +138,14 @@ def _get_position_in_for_tokens(tokens, position): | |
operates under the assumptions that the given tokens represent a for loop | |
and that the given position is within the tokens. | |
- :param tokens: The tokens representing the for loop (clang extent) | |
- :param position: A tuple holding (line, column) of the position to | |
- identify. | |
- :return: A FOR_POSITION object indicating where the position is | |
- semantically. | |
+ :param tokens: | |
+ The tokens representing the for loop (clang extent) | |
+ :param position: | |
+ A tuple holding (line, column) of the position to | |
+ identify. | |
+ :return: | |
+ A FOR_POSITION object indicating where the position is | |
+ semantically. | |
""" | |
state = FOR_POSITION.INIT | |
next_state = state | |
@@ -166,9 +186,12 @@ def _get_positions_in_for_loop(stack): | |
Investigates all FOR_STMT objects in the stack and checks for each in | |
what position the given cursor is. | |
- :param cursor: The cursor to investigate. | |
- :param stack: The stack of parental cursors. | |
- :return: A list of semantic FOR_POSITION's within for loops. | |
+ :param cursor: | |
+ The cursor to investigate. | |
+ :param stack: | |
+ The stack of parental cursors. | |
+ :return: | |
+ A list of semantic FOR_POSITION's within for loops. | |
""" | |
results = [] | |
for elem, _ in stack: | |
@@ -184,8 +207,10 @@ def _get_binop_operator(cursor): | |
""" | |
Returns the operator token of a binary operator cursor. | |
- :param cursor: A cursor of kind BINARY_OPERATOR. | |
- :return: The token object containing the actual operator or None. | |
+ :param cursor: | |
+ A cursor of kind BINARY_OPERATOR. | |
+ :return: | |
+ The token object containing the actual operator or None. | |
""" | |
children = list(cursor.get_children()) | |
operator_min_begin = (children[0].location.line, | |
@@ -207,10 +232,13 @@ def _stack_contains_operators(stack, operators): | |
""" | |
Checks if one of the given operators is within the stack. | |
- :param stack: The stack holding a tuple holding the parent cursors | |
- and the child number. | |
- :param operators: A list of strings. E.g. ["+", "-"] | |
- :return: True if the operator was found. | |
+ :param stack: | |
+ The stack holding a tuple holding the parent cursors | |
+ and the child number. | |
+ :param operators: | |
+ A list of strings. E.g. ["+", "-"] | |
+ :return: | |
+ True if the operator was found. | |
""" | |
for elem, _ in stack: | |
if elem.kind in [CursorKind.BINARY_OPERATOR, | |
@@ -381,8 +409,10 @@ def _loop_level(stack): | |
""" | |
Investigates the stack to determine the loop level. | |
- :param stack: A stack of clang cursors. | |
- :return: An integer representing the level of nested loops. | |
+ :param stack: | |
+ A stack of clang cursors. | |
+ :return: | |
+ An integer representing the level of nested loops. | |
""" | |
positions_in_for = _get_positions_in_for_loop(stack) | |
return (positions_in_for.count(FOR_POSITION.INC) + | |
@@ -460,8 +490,10 @@ def counting_condition(value): | |
This is a custom converter to convert a setting from coala into counting | |
condition function objects for this bear only. | |
- :param value: An object that can be converted to a list. | |
- :return: A list of functions (counting conditions) | |
+ :param value: | |
+ An object that can be converted to a list. | |
+ :return: | |
+ A list of functions (counting conditions) | |
""" | |
str_list = list(value) | |
result_list = [] | |
diff --git a/bears/c_languages/codeclone_detection/ClangFunctionDifferenceBear.py b/bears/c_languages/codeclone_detection/ClangFunctionDifferenceBear.py | |
index a72901b..c9f04e9 100644 | |
--- a/bears/c_languages/codeclone_detection/ClangFunctionDifferenceBear.py | |
+++ b/bears/c_languages/codeclone_detection/ClangFunctionDifferenceBear.py | |
@@ -26,24 +26,25 @@ counting_condition_dict = typed_ordered_dict( | |
default_cc_dict = counting_condition_dict(StringConverter( | |
""" | |
-used: 0, | |
-returned: 1.4, | |
-is_condition: 0, | |
-in_condition: 1.4, | |
-in_second_level_condition: 1.4, | |
-in_third_level_condition: 1.0, | |
-is_assignee: 0, | |
-is_assigner: 0.6, | |
-loop_content: 0, | |
-second_level_loop_content, | |
-third_level_loop_content, | |
-is_param: 2, | |
-is_called: 1.4, | |
-is_call_param: 0.0, | |
-in_sum: 2.0, | |
-in_product: 0, | |
-in_binary_operation, | |
-member_accessed""")) | |
+ : 0, | |
+ rned: 1.4, | |
+ ondition: 0, | |
+ ondition: 1.4, | |
+ econd_level_condition: 1.4, | |
+ hird_level_condition: 1.0, | |
+ ssignee: 0, | |
+ ssigner: 0.6, | |
+ _content: 0, | |
+ nd_level_loop_content, | |
+ d_level_loop_content, | |
+ aram: 2, | |
+ alled: 1.4, | |
+ all_param: 0.0, | |
+ um: 2.0, | |
+ roduct: 0, | |
+ inary_operation, | |
+ er_accessed | |
+ """)) | |
def get_difference(function_pair, | |
@@ -54,22 +55,28 @@ def get_difference(function_pair, | |
""" | |
Retrieves the difference between two functions using the munkres algorithm. | |
- :param function_pair: A tuple containing both indices for the | |
- count_matrices dictionary. | |
- :param count_matrices: A dictionary holding CMs. | |
- :param average_calculation: If set to true the difference calculation | |
- function will take the average of all variable | |
- differences as the difference, else it will | |
- normalize the function as a whole and thus | |
- weighting in variables dependent on their size. | |
- :param poly_postprocessing: If set to true, the difference value of big | |
- function pairs will be reduced using a | |
- polynomial approach. | |
- :param exp_postprocessing: If set to true, the difference value of big | |
- function pairs will be reduced using an | |
- exponential approach. | |
- :return: A tuple containing both function ids and their | |
- difference. | |
+ :param function_pair: | |
+ A tuple containing both indices for the | |
+ count_matrices dictionary. | |
+ :param count_matrices: | |
+ A dictionary holding CMs. | |
+ :param average_calculation: | |
+ If set to true the difference calculation | |
+ function will take the average of all variable | |
+ differences as the difference, else it will | |
+ normalize the function as a whole and thus | |
+ weighting in variables dependent on their size. | |
+ :param poly_postprocessing: | |
+ If set to true, the difference value of big | |
+ function pairs will be reduced using a | |
+ polynomial approach. | |
+ :param exp_postprocessing: | |
+ If set to true, the difference value of big | |
+ function pairs will be reduced using an | |
+ exponential approach. | |
+ :return: | |
+ A tuple containing both function ids and their | |
+ difference. | |
""" | |
function_1, function_2 = function_pair | |
return (function_1, | |
diff --git a/bears/c_languages/codeclone_detection/CloneDetectionRoutines.py b/bears/c_languages/codeclone_detection/CloneDetectionRoutines.py | |
index 87ce367..b11e9dc 100644 | |
--- a/bears/c_languages/codeclone_detection/CloneDetectionRoutines.py | |
+++ b/bears/c_languages/codeclone_detection/CloneDetectionRoutines.py | |
@@ -21,9 +21,11 @@ def exclude_function(count_matrix): | |
of lower then 10 are very likely only declarations or empty and to be | |
ignored. (Constants are not taken into account.) | |
- :param count_matrix: A dictionary with count vectors representing all | |
- variables for a function. | |
- :return: True if the function is useless for evaluation. | |
+ :param count_matrix: | |
+ A dictionary with count vectors representing all | |
+ variables for a function. | |
+ :return: | |
+ True if the function is useless for evaluation. | |
""" | |
var_list = [cv for cv in count_matrix.values() | |
if cv.category is CountVector.Category.reference] | |
@@ -45,17 +47,22 @@ def get_count_matrices(count_vector_creator, | |
Retrieves matrices holding count vectors for all variables for all | |
functions in the given file. | |
- :param count_vector_creator: A object with a get_vectors_for_file method | |
- taking a filename as argument. | |
- :param filenames: The files to create count vectors for. | |
- :param progress_callback: A function with one float argument which is | |
- called after processing each file with the | |
- progress percentage (float) as an argument. | |
- :param extra_include_paths: A list containing additional include paths. | |
- :return: A dict holding a tuple of (file, line, | |
- function) as key and as value a dict with | |
- variable names as key and count vector | |
- objects as value. | |
+ :param count_vector_creator: | |
+ A object with a get_vectors_for_file method | |
+ taking a filename as argument. | |
+ :param filenames: | |
+ The files to create count vectors for. | |
+ :param progress_callback: | |
+ A function with one float argument which is | |
+ called after processing each file with the | |
+ progress percentage (float) as an argument. | |
+ :param extra_include_paths: | |
+ A list containing additional include paths. | |
+ :return: | |
+ A dict holding a tuple of (file, line, | |
+ function) as key and as value a dict with | |
+ variable names as key and count vector | |
+ objects as value. | |
""" | |
result = {} | |
maxlen = len(filenames) | |
@@ -79,9 +86,12 @@ def pad_count_vectors(cm1, cm2): | |
""" | |
Pads the smaller count matrix with zeroed count vectors. | |
- :param cm1: First cm. Will not be modified. | |
- :param cm2: Second cm. Will not be modified. | |
- :return: A tuple holding two cms. | |
+ :param cm1: | |
+ First cm. Will not be modified. | |
+ :param cm2: | |
+ Second cm. Will not be modified. | |
+ :return: | |
+ A tuple holding two cms. | |
""" | |
cm1len = len(cm1) | |
cm2len = len(cm2) | |
@@ -127,22 +137,26 @@ def get_difference(matching_iterator, | |
clones at the same difference value than big functions which may provide a | |
better refactoring opportunity for the user. | |
- :return: A difference value between 0 and 1. | |
- | |
- :param matching_iterator: A list holding tuples of an absolute difference | |
- value and a value to normalize the difference | |
- into a range of [0, 1]. | |
- :param average_calculation: If set to true this function will take the | |
- average of all variable differences as the | |
- difference, else it will normalize the | |
- function as a whole and thus weighting in | |
- variables dependent on their size. | |
- :param poly_postprocessing: If set to true, the difference value of big | |
- function pairs will be reduced using a | |
- polynomial approach. | |
- :param exp_postprocessing: If set to true, the difference value of big | |
- function pairs will be reduced using an | |
- exponential approach. | |
+ :return: | |
+ A difference value between 0 and 1. | |
+ :param matching_iterator: | |
+ A list holding tuples of an absolute difference | |
+ value and a value to normalize the difference | |
+ into a range of [0, 1]. | |
+ :param average_calculation: | |
+ If set to true this function will take the | |
+ average of all variable differences as the | |
+ difference, else it will normalize the | |
+ function as a whole and thus weighting in | |
+ variables dependent on their size. | |
+ :param poly_postprocessing: | |
+ If set to true, the difference value of big | |
+ function pairs will be reduced using a | |
+ polynomial approach. | |
+ :param exp_postprocessing: | |
+ If set to true, the difference value of big | |
+ function pairs will be reduced using an | |
+ exponential approach. | |
""" | |
norm_sum = sum(norm for diff, norm in matching_iterator) | |
@@ -175,21 +189,27 @@ def compare_functions(cm1, | |
clones at the same difference value than big functions which may provide a | |
better refactoring opportunity for the user. | |
- :param cm1: Count vector dict for the first function. | |
- :param cm2: Count vector dict for the second function. | |
- :param average_calculation: If set to true the difference calculation | |
- function will take the average of all variable | |
- differences as the difference, else it will | |
- normalize the function as a whole and thus | |
- weighting in variables dependent on their size. | |
- :param poly_postprocessing: If set to true, the difference value of big | |
- function pairs will be reduced using a | |
- polynomial approach. | |
- :param exp_postprocessing: If set to true, the difference value of big | |
- function pairs will be reduced using an | |
- exponential approach. | |
- :return: The difference between these functions, 0 is | |
- identical and 1 is not similar at all. | |
+ :param cm1: | |
+ Count vector dict for the first function. | |
+ :param cm2: | |
+ Count vector dict for the second function. | |
+ :param average_calculation: | |
+ If set to true the difference calculation | |
+ function will take the average of all variable | |
+ differences as the difference, else it will | |
+ normalize the function as a whole and thus | |
+ weighting in variables dependent on their size. | |
+ :param poly_postprocessing: | |
+ If set to true, the difference value of big | |
+ function pairs will be reduced using a | |
+ polynomial approach. | |
+ :param exp_postprocessing: | |
+ If set to true, the difference value of big | |
+ function pairs will be reduced using an | |
+ exponential approach. | |
+ :return: | |
+ The difference between these functions, 0 is | |
+ identical and 1 is not similar at all. | |
""" | |
assert 0 not in (len(cm1), len(cm2)) | |
diff --git a/bears/c_languages/codeclone_detection/CountVector.py b/bears/c_languages/codeclone_detection/CountVector.py | |
index f82f4f3..4fbc97f 100644 | |
--- a/bears/c_languages/codeclone_detection/CountVector.py | |
+++ b/bears/c_languages/codeclone_detection/CountVector.py | |
@@ -17,13 +17,17 @@ class CountVector: | |
""" | |
Creates a new count vector. | |
- :param name: The name of the variable in the original code. | |
- :param category: The category of the variable. | |
- :param conditions: The counting conditions as list of function objects, | |
- each shall return true when getting data indicating | |
- that this occurrence should be counted. | |
- :param weightings: Optional factors to weight counting conditions. | |
- Defaults to 1 for all conditions. | |
+ :param name: | |
+ The name of the variable in the original code. | |
+ :param category: | |
+ The category of the variable. | |
+ :param conditions: | |
+ The counting conditions as list of function objects, | |
+ each shall return true when getting data indicating | |
+ that this occurrence should be counted. | |
+ :param weightings: | |
+ Optional factors to weight counting conditions. | |
+ Defaults to 1 for all conditions. | |
""" | |
self.name = name | |
self.category = category | |
@@ -41,7 +45,8 @@ class CountVector: | |
Creates a new CountVector object with the same counting conditions | |
and weightings but initializes it to zero. | |
- :return: A CountVector object. | |
+ :return: | |
+ A CountVector object. | |
""" | |
return CountVector(name, | |
category=self.category, | |
@@ -79,9 +84,11 @@ class CountVector: | |
normalization since this value is guaranteed to be bigger or equal | |
the difference value of those two vectors. | |
- :param other: The vector to normalize with. | |
- :return: A float value bigger or equal than the difference | |
- between self and other. | |
+ :param other: | |
+ The vector to normalize with. | |
+ :return: | |
+ A float value bigger or equal than the difference | |
+ between self and other. | |
""" | |
return sqrt(sum(max(x, y)**2 for x, y in zip(self, other))) | |
@@ -90,8 +97,10 @@ class CountVector: | |
Calculates an absolute difference value. 0 means no difference, | |
i.e. the count vectors are identical. | |
- :param other: The CountVector to calculate the difference to. | |
- :return: An absolute difference value. | |
+ :param other: | |
+ The CountVector to calculate the difference to. | |
+ :return: | |
+ An absolute difference value. | |
""" | |
assert isinstance(other, CountVector) | |
assert len(other) == len(self) | |
diff --git a/bears/cmake/CMakeLintBear.py b/bears/cmake/CMakeLintBear.py | |
index e5f95fe..6a038b6 100644 | |
--- a/bears/cmake/CMakeLintBear.py | |
+++ b/bears/cmake/CMakeLintBear.py | |
@@ -23,7 +23,8 @@ class CMakeLintBear: | |
def create_arguments(filename, file, config_file, | |
cmakelint_config: path=''): | |
""" | |
- :param cmakelint_config: The location of the cmakelintrc config file. | |
+ :param cmakelint_config: | |
+ The location of the cmakelintrc config file. | |
""" | |
args = () | |
if cmakelint_config: | |
diff --git a/bears/documentation/DocumentationStyleBear.py b/bears/documentation/DocumentationStyleBear.py | |
index b56f9f6..c797e0c 100644 | |
--- a/bears/documentation/DocumentationStyleBear.py | |
+++ b/bears/documentation/DocumentationStyleBear.py | |
@@ -28,16 +28,17 @@ class DocumentationStyleBear(LocalBear): | |
The first line needs to have no indentation. | |
- Following lines can have indentation | |
- :param x: | |
- 4 space indent | |
- :return: | |
- also 4 space indent | |
- following lines are also 4 space indented | |
- | |
- :param language: The programming language of the file(s). | |
- :param docstyle: The docstyle to use. For example ``default`` or | |
- ``doxygen``. Docstyles are language dependent, meaning | |
- not every language is supported by a certain docstyle. | |
+ :param x: | |
+ 4 space indent | |
+ :return: | |
+ also 4 space indent | |
+ following lines are also 4 space indented | |
+ :param language: | |
+ The programming language of the file(s). | |
+ :param docstyle: | |
+ The docstyle to use. For example ``default`` or | |
+ ``doxygen``. Docstyles are language dependent, meaning | |
+ not every language is supported by a certain docstyle. | |
""" | |
for doc_comment in extract_documentation(file, language, docstyle): | |
parsed = doc_comment.parse() | |
diff --git a/bears/general/AnnotationBear.py b/bears/general/AnnotationBear.py | |
index 17dc53a..6493248 100644 | |
--- a/bears/general/AnnotationBear.py | |
+++ b/bears/general/AnnotationBear.py | |
@@ -236,7 +236,7 @@ class AnnotationBear(LocalBear): | |
The string which specifies how a string starts. | |
:param string_end: | |
The string which specifies how a string ends. | |
- :position: | |
+ :position: | |
An integer identifying the position where the string started. | |
:return: | |
A SourceRange object identifying the range of the single-line | |
@@ -272,7 +272,7 @@ class AnnotationBear(LocalBear): | |
The name of the file. | |
:param comment: | |
The string which specifies the comment. | |
- :position: | |
+ :position: | |
An integer identifying the position where the string started. | |
:return: | |
A SourceRange object identifying the range of the single-line | |
diff --git a/bears/general/IndentationBear.py b/bears/general/IndentationBear.py | |
index 168fdab..7f49a24 100644 | |
--- a/bears/general/IndentationBear.py | |
+++ b/bears/general/IndentationBear.py | |
@@ -163,16 +163,21 @@ class IndentationBear(LocalBear): | |
""" | |
Gets the absolute indentation of all the encapsulators. | |
- :param file: A tuple of strings. | |
- :param filename: Name of file. | |
- :param encaps_pos: A tuple ofSourceRanges of code regions | |
- trapped in between a matching pair of | |
- encapsulators. | |
- :param annotation_dict: A dictionary containing sourceranges of all the | |
- strings and comments within a file. | |
- :return: A tuple of tuples with first element as the | |
- range of encapsulator and second element as the | |
- indent of its elements. | |
+ :param file: | |
+ A tuple of strings. | |
+ :param filename: | |
+ Name of file. | |
+ :param encaps_pos: | |
+ A tuple ofSourceRanges of code regions | |
+ trapped in between a matching pair of | |
+ encapsulators. | |
+ :param annotation_dict: | |
+ A dictionary containing sourceranges of all the | |
+ strings and comments within a file. | |
+ :return: | |
+ A tuple of tuples with first element as the | |
+ range of encapsulator and second element as the | |
+ indent of its elements. | |
""" | |
indent_of_range = [] | |
for encaps in encaps_pos: | |
@@ -191,19 +196,26 @@ class IndentationBear(LocalBear): | |
""" | |
Gets the level of indentation of each line. | |
- :param file: File that needs to be checked in the form of | |
- a list of strings. | |
- :param filename: Name of the file that needs to be checked. | |
- :param indent_types: A dictionary with keys as start of indent and | |
- values as their corresponding closing indents. | |
- :param annotation_dict: A dictionary containing sourceranges of all the | |
- strings and comments within a file. | |
- :param encapsulators: A tuple of sourceranges of all encapsulators of | |
- a language. | |
- :param comments: A dict containing all the types of comment | |
- specifiers in a language. | |
- :return: A tuple containing the levels of indentation of | |
- each line. | |
+ :param file: | |
+ File that needs to be checked in the form of | |
+ a list of strings. | |
+ :param filename: | |
+ Name of the file that needs to be checked. | |
+ :param indent_types: | |
+ A dictionary with keys as start of indent and | |
+ values as their corresponding closing indents. | |
+ :param annotation_dict: | |
+ A dictionary containing sourceranges of all the | |
+ strings and comments within a file. | |
+ :param encapsulators: | |
+ A tuple of sourceranges of all encapsulators of | |
+ a language. | |
+ :param comments: | |
+ A dict containing all the types of comment | |
+ specifiers in a language. | |
+ :return: | |
+ A tuple containing the levels of indentation of | |
+ each line. | |
""" | |
ranges = [] | |
for indent_specifier in indent_types: | |
@@ -248,21 +260,27 @@ class IndentationBear(LocalBear): | |
Gets a sourceranges of all the indentation blocks present inside the | |
file. | |
- :param file: File that needs to be checked in the form of | |
- a list of strings. | |
- :param filename: Name of the file that needs to be checked. | |
- :param open_specifier: A character or string indicating that the | |
- block has begun. | |
- :param close_specifier: A character or string indicating that the block | |
- has ended. | |
- :param annotation_dict: A dictionary containing sourceranges of all the | |
- strings and comments within a file. | |
- :return: A tuple with the first source range being | |
- the range of the outermost indentation while | |
- last being the range of the most | |
- nested/innermost indentation. | |
- Equal level indents appear in the order of | |
- first encounter or left to right. | |
+ :param file: | |
+ File that needs to be checked in the form of | |
+ a list of strings. | |
+ :param filename: | |
+ Name of the file that needs to be checked. | |
+ :param open_specifier: | |
+ A character or string indicating that the | |
+ block has begun. | |
+ :param close_specifier: | |
+ A character or string indicating that the block | |
+ has ended. | |
+ :param annotation_dict: | |
+ A dictionary containing sourceranges of all the | |
+ strings and comments within a file. | |
+ :return: | |
+ A tuple with the first source range being | |
+ the range of the outermost indentation while | |
+ last being the range of the most | |
+ nested/innermost indentation. | |
+ Equal level indents appear in the order of | |
+ first encounter or left to right. | |
""" | |
ranges = [] | |
@@ -319,19 +337,26 @@ class IndentationBear(LocalBear): | |
""" | |
Gets the range of all blocks which do not have an un-indent specifer. | |
- :param file: File that needs to be checked in the form of | |
- a list of strings. | |
- :param filename: Name of the file that needs to be checked. | |
- :param indent_specifier: A character or string indicating that the | |
- indentation should begin. | |
- :param annotation_dict: A dictionary containing sourceranges of all the | |
- strings and comments within a file. | |
- :param encapsulators: A tuple of sourceranges of all encapsulators of | |
- a language. | |
- :param comments: A dict containing all the types of comments | |
- specifiers in a language. | |
- :return: A tuple of SourceRanges of blocks without | |
- un-indent specifiers. | |
+ :param file: | |
+ File that needs to be checked in the form of | |
+ a list of strings. | |
+ :param filename: | |
+ Name of the file that needs to be checked. | |
+ :param indent_specifier: | |
+ A character or string indicating that the | |
+ indentation should begin. | |
+ :param annotation_dict: | |
+ A dictionary containing sourceranges of all the | |
+ strings and comments within a file. | |
+ :param encapsulators: | |
+ A tuple of sourceranges of all encapsulators of | |
+ a language. | |
+ :param comments: | |
+ A dict containing all the types of comments | |
+ specifiers in a language. | |
+ :return: | |
+ A tuple of SourceRanges of blocks without | |
+ un-indent specifiers. | |
""" | |
specifiers = list(self.get_valid_sequences( | |
file, | |
@@ -369,18 +394,24 @@ class IndentationBear(LocalBear): | |
""" | |
A vaild sequence is a sequence that is outside of comments or strings. | |
- :param file: File that needs to be checked in the form of | |
- a list of strings. | |
- :param sequence: Sequence whose validity is to be checked. | |
- :param annotation_dict: A dictionary containing sourceranges of all the | |
- strings and comments within a file. | |
- :param encapsulators: A tuple of SourceRanges of code regions | |
- trapped in between a matching pair of | |
- encapsulators. | |
- :param check_ending: Check whether sequence falls at the end of the | |
- line. | |
- :return: A tuple of AbsolutePosition's of all occurances | |
- of sequence outside of string's and comments. | |
+ :param file: | |
+ File that needs to be checked in the form of | |
+ a list of strings. | |
+ :param sequence: | |
+ Sequence whose validity is to be checked. | |
+ :param annotation_dict: | |
+ A dictionary containing sourceranges of all the | |
+ strings and comments within a file. | |
+ :param encapsulators: | |
+ A tuple of SourceRanges of code regions | |
+ trapped in between a matching pair of | |
+ encapsulators. | |
+ :param check_ending: | |
+ Check whether sequence falls at the end of the | |
+ line. | |
+ :return: | |
+ A tuple of AbsolutePosition's of all occurances | |
+ of sequence outside of string's and comments. | |
""" | |
file_string = ''.join(file) | |
# tuple since order is important | |
@@ -430,10 +461,14 @@ def get_indent_of_specifier(file, current_line, encapsulators): | |
""" | |
Get indentation of the indent specifer itself. | |
- :param file: A tuple of strings. | |
- :param current_line: Line number of indent specifier (initial 1) | |
- :param encapsulators: A tuple with all the ranges of encapsulators | |
- :return: Indentation of the specifier. | |
+ :param file: | |
+ A tuple of strings. | |
+ :param current_line: | |
+ Line number of indent specifier (initial 1) | |
+ :param encapsulators: | |
+ A tuple with all the ranges of encapsulators | |
+ :return: | |
+ Indentation of the specifier. | |
""" | |
start = current_line | |
_range = 0 | |
@@ -458,17 +493,24 @@ def get_first_unindent(indent, | |
""" | |
Get the first case of a valid unindentation. | |
- :param indent: No. of spaces to check unindent against. | |
- :param file: A tuple of strings. | |
- :param start_line: The line from where to start searching for | |
- unindent. | |
- :param annotation_dict: A dictionary containing sourceranges of all the | |
- strings and comments within a file. | |
- :param encapsulators: A tuple of SourceRanges of code regions trapped in | |
- between a matching pair of encapsulators. | |
- :param comments: A dict containing all the types of comments | |
- specifiers in a language. | |
- :return: The line where unindent is found (intial 0). | |
+ :param indent: | |
+ No. of spaces to check unindent against. | |
+ :param file: | |
+ A tuple of strings. | |
+ :param start_line: | |
+ The line from where to start searching for | |
+ unindent. | |
+ :param annotation_dict: | |
+ A dictionary containing sourceranges of all the | |
+ strings and comments within a file. | |
+ :param encapsulators: | |
+ A tuple of SourceRanges of code regions trapped in | |
+ between a matching pair of encapsulators. | |
+ :param comments: | |
+ A dict containing all the types of comments | |
+ specifiers in a language. | |
+ :return: | |
+ The line where unindent is found (intial 0). | |
""" | |
line_nr = start_line | |
@@ -518,10 +560,13 @@ def get_element_indent(file, encaps): | |
""" | |
Gets indent of elements inside encapsulator. | |
- :param file: A tuple of strings. | |
- :param encaps: SourceRange of an encapsulator. | |
- :return: The number of spaces params are indented relative to | |
- the start line of encapsulator. | |
+ :param file: | |
+ A tuple of strings. | |
+ :param encaps: | |
+ SourceRange of an encapsulator. | |
+ :return: | |
+ The number of spaces params are indented relative to | |
+ the start line of encapsulator. | |
""" | |
line_nr = encaps.start.line - 1 | |
start_indent = get_indent_of_line(file, line_nr) | |
diff --git a/bears/general/InvalidLinkBear.py b/bears/general/InvalidLinkBear.py | |
index 16b7815..aef3a70 100644 | |
--- a/bears/general/InvalidLinkBear.py | |
+++ b/bears/general/InvalidLinkBear.py | |
@@ -118,17 +118,21 @@ class InvalidLinkBear(LocalBear): | |
`do_not_ever_open = 'https://api.acme.inc/delete-all-data'` wiping out | |
all your data. | |
- :param network_timeout: A dict mapping URLs and timeout to be | |
- used for that URL. All the URLs that have | |
- the same host as that of URLs provided | |
- will be passed that timeout. It can also | |
- contain a wildcard timeout entry with key | |
- '*'. The timeout of all the websites not | |
- in the dict will be the value of the key | |
- '*'. | |
- :param link_ignore_regex: A regex for urls to ignore. | |
- :param link_ignore_list: Comma separated url globs to ignore | |
- :param follow_redirects: Set to true to autocorrect redirects. | |
+ :param network_timeout: | |
+ A dict mapping URLs and timeout to be | |
+ used for that URL. All the URLs that have | |
+ the same host as that of URLs provided | |
+ will be passed that timeout. It can also | |
+ contain a wildcard timeout entry with key | |
+ '*'. The timeout of all the websites not | |
+ in the dict will be the value of the key | |
+ '*'. | |
+ :param link_ignore_regex: | |
+ A regex for urls to ignore. | |
+ :param link_ignore_list: | |
+ Comma separated url globs to ignore | |
+ :param follow_redirects: | |
+ Set to true to autocorrect redirects. | |
""" | |
network_timeout = {urlparse(url).netloc | |
if not url == '*' else '*': timeout | |
diff --git a/bears/general/LineCountBear.py b/bears/general/LineCountBear.py | |
index 5522f1b..613c03b 100644 | |
--- a/bears/general/LineCountBear.py | |
+++ b/bears/general/LineCountBear.py | |
@@ -15,7 +15,8 @@ class LineCountBear(LocalBear): | |
Count the number of lines in a file and ensure that they are | |
smaller than a given size. | |
- :param max_lines_per_file: Number of lines allowed per file. | |
+ :param max_lines_per_file: | |
+ Number of lines allowed per file. | |
""" | |
file_length = len(file) | |
if file_length > max_lines_per_file: | |
diff --git a/bears/general/QuotesBear.py b/bears/general/QuotesBear.py | |
index f15806e..f8ee65b 100644 | |
--- a/bears/general/QuotesBear.py | |
+++ b/bears/general/QuotesBear.py | |
@@ -59,8 +59,9 @@ class QuotesBear(LocalBear): | |
your preferred quotation style if that kind of quote is not included | |
within the string. Multi line strings are not supported. | |
- :param preferred_quotation: Your preferred quotation character, e.g. | |
- ``"`` or ``'``. | |
+ :param preferred_quotation: | |
+ Your preferred quotation character, e.g. | |
+ ``"`` or ``'``. | |
""" | |
if not isinstance(dependency_results[AnnotationBear.name][0], | |
HiddenResult): | |
diff --git a/bears/generate_package.py b/bears/generate_package.py | |
index 3765ceb..bf4e011 100644 | |
--- a/bears/generate_package.py | |
+++ b/bears/generate_package.py | |
@@ -17,7 +17,8 @@ def touch(file_name): | |
""" | |
Creates an empty file. An existing file remains untouched. | |
- :param file_name: Name of the file. | |
+ :param file_name: | |
+ Name of the file. | |
""" | |
open(file_name, 'a').close() | |
@@ -26,9 +27,12 @@ def create_file_from_template(template_file, output_file, substitution_dict): | |
""" | |
Creates a file from a template file, using a substitution dict. | |
- :param template_file: The template file. | |
- :param output_file: The file to be written. | |
- :param substitution_dict: The dict from which the substitutions are taken. | |
+ :param template_file: | |
+ The template file. | |
+ :param output_file: | |
+ The file to be written. | |
+ :param substitution_dict: | |
+ The dict from which the substitutions are taken. | |
""" | |
with open(template_file) as fl: | |
template = fl.read() | |
@@ -45,12 +49,15 @@ def create_file_structure_for_packages(root_folder, file_to_copy, object_name): | |
Also holds a ``root_folder/object_name/coalaobject_name/__init__.py`` | |
to make the package importable. | |
- :param root_folder: The folder in which the packages are going to be | |
- generated. | |
- :param file_to_copy: The file that is going to be generated the package | |
- for. | |
- :param object_name: The name of the object that is inside the | |
- file_to_copy. | |
+ :param root_folder: | |
+ The folder in which the packages are going to be | |
+ generated. | |
+ :param file_to_copy: | |
+ The file that is going to be generated the package | |
+ for. | |
+ :param object_name: | |
+ The name of the object that is inside the | |
+ file_to_copy. | |
""" | |
upload_package_folder = os.path.join( | |
root_folder, object_name, 'coala' + object_name) | |
@@ -65,7 +72,8 @@ def perform_register(path, file_name): | |
Register the directory to PyPi, after creating a ``sdist`` and | |
a ``bdist_wheel``. | |
- :param path: The file on which the register should be done. | |
+ :param path: | |
+ The file on which the register should be done. | |
""" | |
subprocess.call( | |
[sys.executable, 'setup.py', 'sdist', 'bdist_wheel'], cwd=path) | |
@@ -79,7 +87,8 @@ def perform_upload(path): | |
""" | |
Uploads the directory to PyPi. | |
- :param path: The folder in which the upload should be done. | |
+ :param path: | |
+ The folder in which the upload should be done. | |
""" | |
subprocess.call( | |
['twine', 'upload', path + '/dist/*']) | |
@@ -89,7 +98,8 @@ def create_upload_parser(): | |
""" | |
Creates a parser for command line arguments. | |
- :return: Parser arguments. | |
+ :return: | |
+ Parser arguments. | |
""" | |
parser = argparse.ArgumentParser( | |
description='Generates PyPi packages from bears.') | |
diff --git a/bears/gettext/DennisBear.py b/bears/gettext/DennisBear.py | |
index 2b85ae8..b45cec1 100644 | |
--- a/bears/gettext/DennisBear.py | |
+++ b/bears/gettext/DennisBear.py | |
@@ -34,8 +34,9 @@ class DennisBear: | |
@staticmethod | |
def create_arguments(filename, file, config_file, allow_untranslated=True): | |
""" | |
- :param allow_untranslated: Set to false to display unchanged | |
- translation warning. | |
+ :param allow_untranslated: | |
+ Set to false to display unchanged | |
+ translation warning. | |
""" | |
if allow_untranslated: | |
return ('lint', filename, '--excluderules', 'W302') | |
diff --git a/bears/go/GoErrCheckBear.py b/bears/go/GoErrCheckBear.py | |
index f6ef933..a59f7be 100644 | |
--- a/bears/go/GoErrCheckBear.py | |
+++ b/bears/go/GoErrCheckBear.py | |
@@ -35,18 +35,21 @@ class GoErrCheckBear: | |
""" | |
Bear configuration arguments. | |
- :param ignore: Comma-separated list of pairs of the | |
- form package:regex. For each package, the regex | |
- describes which functions to ignore within that | |
- package. The package may be omitted to have the | |
- regex apply to all packages. | |
- :param ignorepkg: Takes a comma-separated list of package | |
- import paths to ignore. | |
- :param asserts: Enables checking for ignored type assertion | |
- results. | |
- :param blank: Enables checking for assignments of errors to | |
- the blank identifier. | |
- | |
+ :param ignore: | |
+ Comma-separated list of pairs of the | |
+ form package:regex. For each package, the regex | |
+ describes which functions to ignore within that | |
+ package. The package may be omitted to have the | |
+ regex apply to all packages. | |
+ :param ignorepkg: | |
+ Takes a comma-separated list of package | |
+ import paths to ignore. | |
+ :param asserts: | |
+ Enables checking for ignored type assertion | |
+ results. | |
+ :param blank: | |
+ Enables checking for assignments of errors to | |
+ the blank identifier. | |
""" | |
args = () | |
if ignore: | |
diff --git a/bears/go/GoLintBear.py b/bears/go/GoLintBear.py | |
index 364b873..acb10b1 100644 | |
--- a/bears/go/GoLintBear.py | |
+++ b/bears/go/GoLintBear.py | |
@@ -24,7 +24,8 @@ class GoLintBear: | |
def create_arguments(filename, file, config_file, | |
golint_cli_options: str=''): | |
""" | |
- :param golint_cli_options: Any other flags you wish to pass to golint. | |
+ :param golint_cli_options: | |
+ Any other flags you wish to pass to golint. | |
""" | |
args = () | |
if golint_cli_options: | |
diff --git a/bears/hypertext/BootLintBear.py b/bears/hypertext/BootLintBear.py | |
index 651e49c..9949585 100644 | |
--- a/bears/hypertext/BootLintBear.py | |
+++ b/bears/hypertext/BootLintBear.py | |
@@ -29,7 +29,8 @@ class BootLintBear: | |
def create_arguments(filename, file, config_file, | |
bootlint_ignore: typed_list(str)=[]): | |
""" | |
- :param bootlint_ignore: List of checkers to ignore. | |
+ :param bootlint_ignore: | |
+ List of checkers to ignore. | |
""" | |
ignore = ','.join(part.strip() for part in bootlint_ignore) | |
return '--disable=' + ignore, filename | |
diff --git a/bears/hypertext/HTMLLintBear.py b/bears/hypertext/HTMLLintBear.py | |
index 7b4f877..3ce080d 100644 | |
--- a/bears/hypertext/HTMLLintBear.py | |
+++ b/bears/hypertext/HTMLLintBear.py | |
@@ -30,7 +30,8 @@ class HTMLLintBear: | |
def create_arguments(filename, file, config_file, | |
htmllint_ignore: typed_list(str)=()): | |
""" | |
- :param htmllint_ignore: List of checkers to ignore. | |
+ :param htmllint_ignore: | |
+ List of checkers to ignore. | |
""" | |
ignore = ','.join(part.strip() for part in htmllint_ignore) | |
return HTMLLintBear._html_lint, '--disable=' + ignore, filename | |
diff --git a/bears/java/CheckstyleBear.py b/bears/java/CheckstyleBear.py | |
index 9a1d53f..8454517 100644 | |
--- a/bears/java/CheckstyleBear.py | |
+++ b/bears/java/CheckstyleBear.py | |
@@ -67,18 +67,18 @@ class CheckstyleBear: | |
have the special values: | |
- google - Google's Java style. More info at | |
- <http://checkstyle.sourceforge.net/style_configs.html>. | |
+ <http://checkstyle.sourceforge.net/style_configs.html>. | |
- sun - Sun's Java style. These are the same | |
- as the default Eclipse checks. More info at | |
- <http://checkstyle.sourceforge.net/style_configs.html>. | |
+ as the default Eclipse checks. More info at | |
+ <http://checkstyle.sourceforge.net/style_configs.html>. | |
- android-check-easy - The easy Android configs provided by the | |
- android-check eclipse plugin. More info at | |
- <https://github.com/noveogroup/android-check>. | |
+ android-check eclipse plugin. More info at | |
+ <https://github.com/noveogroup/android-check>. | |
- android-check-hard - The hard Android confis provided by the | |
- android-check eclipse plugin. More info at | |
- <https://github.com/noveogroup/android-check>. | |
+ android-check eclipse plugin. More info at | |
+ <https://github.com/noveogroup/android-check>. | |
- geosoft - The Java style followed by GeoSoft. More info at | |
- <http://geosoft.no/development/javastyle.html> | |
+ <http://geosoft.no/development/javastyle.html> | |
""" | |
check_invalid_configuration( | |
checkstyle_configs, use_spaces, indent_size) | |
diff --git a/bears/jinja2/Jinja2Bear.py b/bears/jinja2/Jinja2Bear.py | |
index 5641fa6..7714997 100644 | |
--- a/bears/jinja2/Jinja2Bear.py | |
+++ b/bears/jinja2/Jinja2Bear.py | |
@@ -10,12 +10,14 @@ def generate_spacing_diff(file, filename, line, line_number, | |
""" | |
Generate a diff for incorrectly spaced control or variable tags. | |
- :param match_object: A Match object containing the groups ``open``, | |
- ``close`` containing the opening and closing | |
- delimiters of a Jinja2 tag and ``content`` | |
- containing everything in between. | |
- :param required_spacing: The number of spaces expected after the ``open`` | |
- delimiter and before the ``close`` delimiter | |
+ :param match_object: | |
+ A Match object containing the groups ``open``, | |
+ ``close`` containing the opening and closing | |
+ delimiters of a Jinja2 tag and ``content`` | |
+ containing everything in between. | |
+ :param required_spacing: | |
+ The number of spaces expected after the ``open`` | |
+ delimiter and before the ``close`` delimiter | |
""" | |
diff = Diff(file) | |
@@ -45,13 +47,13 @@ def generate_label_diff(file, filename, line, line_number, | |
Missing labels will be added, wrong ones replaced, content after the | |
label will be left untouched. | |
- | |
- :param match_object: A Match object containing the groups ``close`` | |
- containing the closing delimiters of a control | |
- end tag and the optional group ``label`` | |
- containing the end tag label. | |
- :param expected_label: The expected label for that control block. | |
- | |
+ :param match_object: | |
+ A Match object containing the groups ``close`` | |
+ containing the closing delimiters of a control | |
+ end tag and the optional group ``label`` | |
+ containing the end tag label. | |
+ :param expected_label: | |
+ The expected label for that control block. | |
""" | |
diff = Diff(file) | |
@@ -81,17 +83,20 @@ def has_required_spacing(string, required_spacing): | |
Checks if a string has the required amount of spaces | |
on each side. | |
- :param string: The string which is to be checked. | |
- :param required_spacing: The number of spaces expected on both | |
- sides of the string. | |
- :return: True if the string has the required | |
- number of spaces on both sides, False | |
- otherwise. | |
- | |
- >>> has_required_spacing(" foo ", 2) | |
- True | |
- >>> has_required_spacing(" foo", 1) | |
- False | |
+ :param string: | |
+ The string which is to be checked. | |
+ :param required_spacing: | |
+ The number of spaces expected on both | |
+ sides of the string. | |
+ :return: | |
+ True if the string has the required | |
+ number of spaces on both sides, False | |
+ otherwise. | |
+ | |
+ >>> has_required_spacing(" foo ", 2) | |
+ True | |
+ >>> has_required_spacing(" foo", 1) | |
+ False | |
""" | |
leading_spaces = len(string) - len(string.lstrip(' ')) | |
trailing_spaces = len(string) - len(string.rstrip(' ')) | |
@@ -124,12 +129,14 @@ class Jinja2Bear(LocalBear): | |
Handles incorrectly spaced control tags (if and for), | |
both start and end tags | |
- :param control_spacing: The number of spaces placed around control tags | |
- as required by the settings. | |
- :param match_object: A Match object containing the groups ``open``, | |
- ``close`` containing the opening and closing | |
- delimiters of a Jinja2 tag and ``content`` | |
- containing everything in between. | |
+ :param control_spacing: | |
+ The number of spaces placed around control tags | |
+ as required by the settings. | |
+ :param match_object: | |
+ A Match object containing the groups ``open``, | |
+ ``close`` containing the opening and closing | |
+ delimiters of a Jinja2 tag and ``content`` | |
+ containing everything in between. | |
""" | |
diff = generate_spacing_diff( | |
file, filename, line, line_number, match_object, control_spacing) | |
@@ -295,7 +302,8 @@ class Jinja2Bear(LocalBear): | |
Checks if the control stack is empty and yields a Result for each | |
item left on the stack. | |
- :param filename: The name of the file currently being inspected. | |
+ :param filename: | |
+ The name of the file currently being inspected. | |
""" | |
if len(self.control_stack) > 0: | |
for (_, line_number) in self.control_stack: | |
@@ -341,7 +349,6 @@ class Jinja2Bear(LocalBear): | |
closing tags is invalid syntax and will be reported with | |
MAJOR severity by the bear. | |
- | |
:param variable_spacing: | |
The number of spaces a variable block should be spaced with. | |
Default is 1. | |
diff --git a/bears/js/ESLintBear.py b/bears/js/ESLintBear.py | |
index 48820c0..1521769 100644 | |
--- a/bears/js/ESLintBear.py | |
+++ b/bears/js/ESLintBear.py | |
@@ -36,7 +36,8 @@ class ESLintBear: | |
def create_arguments(filename, file, config_file, | |
eslint_config: str=''): | |
""" | |
- :param eslint_config: The location of the .eslintrc config file. | |
+ :param eslint_config: | |
+ The location of the .eslintrc config file. | |
""" | |
args = ( | |
'--no-ignore', | |
diff --git a/bears/js/JSComplexityBear.py b/bears/js/JSComplexityBear.py | |
index 2522d0e..185513d 100644 | |
--- a/bears/js/JSComplexityBear.py | |
+++ b/bears/js/JSComplexityBear.py | |
@@ -29,7 +29,8 @@ class JSComplexityBear: | |
def process_output(self, output, filename, file, cc_threshold: int=10): | |
""" | |
- :param cc_threshold: Threshold value for cyclomatic complexity | |
+ :param cc_threshold: | |
+ Threshold value for cyclomatic complexity | |
""" | |
message = '{} has a cyclomatic complexity of {}.' | |
if output: | |
diff --git a/bears/js/JSONFormatBear.py b/bears/js/JSONFormatBear.py | |
index 3a7db4c..205df32 100644 | |
--- a/bears/js/JSONFormatBear.py | |
+++ b/bears/js/JSONFormatBear.py | |
@@ -29,10 +29,13 @@ class JSONFormatBear(LocalBear): | |
""" | |
Raises issues for any deviations from the pretty-printed JSON. | |
- :param json_sort: Whether or not keys should be sorted. | |
- :param indent_size: Number of spaces per indentation level. | |
- :param escape_unicode: Whether or not to escape unicode values using | |
- ASCII. | |
+ :param json_sort: | |
+ Whether or not keys should be sorted. | |
+ :param indent_size: | |
+ Number of spaces per indentation level. | |
+ :param escape_unicode: | |
+ Whether or not to escape unicode values using | |
+ ASCII. | |
""" | |
# Output a meaningful message if empty file given as input | |
if len(file) == 0: | |
diff --git a/bears/markdown/MarkdownBear.py b/bears/markdown/MarkdownBear.py | |
index 13a78da..eb997e7 100644 | |
--- a/bears/markdown/MarkdownBear.py | |
+++ b/bears/markdown/MarkdownBear.py | |
@@ -93,7 +93,7 @@ class MarkdownBear: | |
- "1" - 1 space after bullet. | |
- "tab" - Use tab stops to begin a sentence after the bullet. | |
- "mixed" - Use "1" when the list item is only 1 line, "tab" if it | |
- spans multiple. | |
+ spans multiple. | |
:param loose_tables: | |
Whether to use pipes for the outermost borders in a table. | |
:param spaced_tables: | |
diff --git a/bears/matlab/MatlabIndentationBear.py b/bears/matlab/MatlabIndentationBear.py | |
index 691e2bc..7a97d72 100644 | |
--- a/bears/matlab/MatlabIndentationBear.py | |
+++ b/bears/matlab/MatlabIndentationBear.py | |
@@ -21,7 +21,8 @@ class MatlabIndentationBear(LocalBear): | |
indentation for Matlab/Octave code. However, it will not handle hanging | |
indentation or conditions ranging over several lines yet. | |
- :param indent_size: Number of spaces per indentation level. | |
+ :param indent_size: | |
+ Number of spaces per indentation level. | |
""" | |
new_file = tuple(self.reindent(file, indent_size)) | |
diff --git a/bears/natural_language/WriteGoodLintBear.py b/bears/natural_language/WriteGoodLintBear.py | |
index 9969988..89deb2f 100644 | |
--- a/bears/natural_language/WriteGoodLintBear.py | |
+++ b/bears/natural_language/WriteGoodLintBear.py | |
@@ -44,22 +44,30 @@ class WriteGoodLintBear: | |
""" | |
Using ``False`` will enable the check. | |
- :param allow_passive_voice: Allows passive voice. | |
- :param allow_so_beginning: Allows ``So`` at the beginning of | |
- the sentence. | |
- :param allow_adverbs: Allows adverbs that can weaken the | |
- meaning, such as: ``really``, | |
- ``very``, ``extremely``, etc. | |
- :param allow_repeated_words: Allows lexical illusions – cases | |
- where a word is repeated. | |
- :param allow_there_is: Allows ``There is`` or ``There are`` | |
- at the beginning of the sentence. | |
- :param allow_ambiguous_words: Allows ``weasel words`` for example | |
- ``often``, ``probably`` | |
- :param allow_extra_words: Allows wordy phrases and unnecessary | |
- words. | |
- :param allow_cliche_phrases: Allows common cliche phrases in the | |
- sentence. | |
+ :param allow_passive_voice: | |
+ Allows passive voice. | |
+ :param allow_so_beginning: | |
+ Allows ``So`` at the beginning of | |
+ the sentence. | |
+ :param allow_adverbs: | |
+ Allows adverbs that can weaken the | |
+ meaning, such as: ``really``, | |
+ ``very``, ``extremely``, etc. | |
+ :param allow_repeated_words: | |
+ Allows lexical illusions – cases | |
+ where a word is repeated. | |
+ :param allow_there_is: | |
+ Allows ``There is`` or ``There are`` | |
+ at the beginning of the sentence. | |
+ :param allow_ambiguous_words: | |
+ Allows ``weasel words`` for example | |
+ ``often``, ``probably`` | |
+ :param allow_extra_words: | |
+ Allows wordy phrases and unnecessary | |
+ words. | |
+ :param allow_cliche_phrases: | |
+ Allows common cliche phrases in the | |
+ sentence. | |
""" | |
arg_map = { | |
'allow_passive_voice': '--passive', | |
diff --git a/bears/perl/PerlCriticBear.py b/bears/perl/PerlCriticBear.py | |
index 5020621..a2e1165 100644 | |
--- a/bears/perl/PerlCriticBear.py | |
+++ b/bears/perl/PerlCriticBear.py | |
@@ -35,7 +35,8 @@ class PerlCriticBear: | |
def create_arguments(filename, file, config_file, | |
perlcritic_profile: str=''): | |
""" | |
- :param perlcritic_profile: Location of the perlcriticrc config file. | |
+ :param perlcritic_profile: | |
+ Location of the perlcriticrc config file. | |
""" | |
args = ('--no-color',) | |
if perlcritic_profile: | |
diff --git a/bears/python/MypyBear.py b/bears/python/MypyBear.py | |
index f4af295..e6e87ae 100644 | |
--- a/bears/python/MypyBear.py | |
+++ b/bears/python/MypyBear.py | |
@@ -24,8 +24,10 @@ class FlagInfo(namedtuple('FlagInfo', 'arg doc inverse')): | |
""" | |
Check if the flag should be added to the argument list. | |
- :param value: The configuration value. | |
- :return: The flag value, may be negated if the flag specifies so. | |
+ :param value: | |
+ The configuration value. | |
+ :return: | |
+ The flag value, may be negated if the flag specifies so. | |
""" | |
if self.inverse: | |
diff --git a/bears/python/PEP8Bear.py b/bears/python/PEP8Bear.py | |
index f1ec2ea..86ed49b 100644 | |
--- a/bears/python/PEP8Bear.py | |
+++ b/bears/python/PEP8Bear.py | |
@@ -28,13 +28,18 @@ class PEP8Bear(LocalBear): | |
Detects and fixes PEP8 incompliant code. This bear will not change | |
functionality of the code in any way. | |
- :param max_line_length: Maximum number of characters for a line. | |
- :param indent_size: Number of spaces per indentation level. | |
- :param pep_ignore: A list of errors/warnings to ignore. | |
- :param pep_select: A list of errors/warnings to exclusively | |
- apply. | |
- :param local_pep8_config: Set to true if autopep8 should use a config | |
- file as if run normally from this directory. | |
+ :param max_line_length: | |
+ Maximum number of characters for a line. | |
+ :param indent_size: | |
+ Number of spaces per indentation level. | |
+ :param pep_ignore: | |
+ A list of errors/warnings to ignore. | |
+ :param pep_select: | |
+ A list of errors/warnings to exclusively | |
+ apply. | |
+ :param local_pep8_config: | |
+ Set to true if autopep8 should use a config | |
+ file as if run normally from this directory. | |
""" | |
options = {'ignore': pep_ignore, | |
'select': pep_select, | |
diff --git a/bears/python/PEP8NotebookBear.py b/bears/python/PEP8NotebookBear.py | |
index ce4e49d..e0b3bc7 100644 | |
--- a/bears/python/PEP8NotebookBear.py | |
+++ b/bears/python/PEP8NotebookBear.py | |
@@ -23,9 +23,11 @@ def notebook_node_from_string_list(string_list): | |
Reads a notebook from a string list and returns the NotebookNode | |
object. | |
- :param string_list: The notebook file contents as list of strings | |
- (linewise). | |
- :return: The notebook as NotebookNode. | |
+ :param string_list: | |
+ The notebook file contents as list of strings | |
+ (linewise). | |
+ :return: | |
+ The notebook as NotebookNode. | |
""" | |
return nbformat.reads(''.join(string_list), nbformat.NO_CONVERT) | |
@@ -34,8 +36,10 @@ def notebook_node_to_string_list(notebook_node): | |
""" | |
Writes a NotebookNode to a list of strings. | |
- :param notebook_node: The notebook as NotebookNode to write. | |
- :return: The notebook as list of strings (linewise). | |
+ :param notebook_node: | |
+ The notebook as NotebookNode to write. | |
+ :return: | |
+ The notebook as list of strings (linewise). | |
""" | |
return nbformat.writes(notebook_node, nbformat.NO_CONVERT).splitlines(True) | |
@@ -82,13 +86,18 @@ class PEP8NotebookBear(LocalBear): | |
Detects and fixes PEP8 incompliant code in Jupyter Notebooks. This bear | |
will not change functionality of the code in any way. | |
- :param max_line_length: Maximum number of characters for a line. | |
- :param indent_size: Number of spaces per indent level. | |
- :param pep_ignore: A list of errors/warnings to ignore. | |
- :param pep_select: A list of errors/warnings to exclusively | |
- apply. | |
- :param local_pep8_config: Set to true if autopep8 should use a config | |
- file as if run normally from this directory. | |
+ :param max_line_length: | |
+ Maximum number of characters for a line. | |
+ :param indent_size: | |
+ Number of spaces per indent level. | |
+ :param pep_ignore: | |
+ A list of errors/warnings to ignore. | |
+ :param pep_select: | |
+ A list of errors/warnings to exclusively | |
+ apply. | |
+ :param local_pep8_config: | |
+ Set to true if autopep8 should use a config | |
+ file as if run normally from this directory. | |
""" | |
options = {'ignore': pep_ignore, | |
'select': pep_select, | |
diff --git a/bears/python/PyImportSortBear.py b/bears/python/PyImportSortBear.py | |
index b82c264..3d9a73c 100644 | |
--- a/bears/python/PyImportSortBear.py | |
+++ b/bears/python/PyImportSortBear.py | |
@@ -106,7 +106,7 @@ class PyImportSortBear(LocalBear): | |
The default section to place imports in, if their section can | |
not be automatically determined. | |
:param force_grid_wrap_imports: | |
- Force "from" imports to be grid wrapped regardless of line length. | |
+ Force "from" imports to be grid wrapped regardless of line length. | |
:param force_single_line_imports: | |
If set to true - instead of wrapping multi-line from style imports, | |
each import will be forced to display on its own line. | |
diff --git a/bears/python/PyLintBear.py b/bears/python/PyLintBear.py | |
index 13b1fd1..a66f488 100644 | |
--- a/bears/python/PyLintBear.py | |
+++ b/bears/python/PyLintBear.py | |
@@ -37,13 +37,17 @@ class PyLintBear: | |
pylint_cli_options: str='', | |
pylint_rcfile: str=''): | |
""" | |
- :param pylint_disable: Disable the message, report, category or | |
- checker with the given id(s). | |
- :param pylint_enable: Enable the message, report, category or | |
- checker with the given id(s). | |
- :param pylint_cli_options: Any command line options you wish to be | |
- passed to pylint. | |
- :param pylint_rcfile: The rcfile for PyLint. | |
+ :param pylint_disable: | |
+ Disable the message, report, category or | |
+ checker with the given id(s). | |
+ :param pylint_enable: | |
+ Enable the message, report, category or | |
+ checker with the given id(s). | |
+ :param pylint_cli_options: | |
+ Any command line options you wish to be | |
+ passed to pylint. | |
+ :param pylint_rcfile: | |
+ The rcfile for PyLint. | |
""" | |
args = ('--reports=n', '--persistent=n', | |
'--msg-template="L{line}C{column}: {msg_id} - {msg}"') | |
diff --git a/bears/python/RadonBear.py b/bears/python/RadonBear.py | |
index c93e38b..6d20399 100644 | |
--- a/bears/python/RadonBear.py | |
+++ b/bears/python/RadonBear.py | |
@@ -24,12 +24,15 @@ class RadonBear(LocalBear): | |
""" | |
Uses radon to compute complexity of a given file. | |
- :param radon_ranks_info: The ranks (given by radon) to | |
- treat as severity INFO. | |
- :param radon_ranks_normal: The ranks (given by radon) to | |
- treat as severity NORMAL. | |
- :param radon_ranks_major: The ranks (given by radon) to | |
- treat as severity MAJOR. | |
+ :param radon_ranks_info: | |
+ The ranks (given by radon) to | |
+ treat as severity INFO. | |
+ :param radon_ranks_normal: | |
+ The ranks (given by radon) to | |
+ treat as severity NORMAL. | |
+ :param radon_ranks_major: | |
+ The ranks (given by radon) to | |
+ treat as severity MAJOR. | |
""" | |
severity_map = { | |
RESULT_SEVERITY.INFO: radon_ranks_info, | |
diff --git a/bears/python/YapfBear.py b/bears/python/YapfBear.py | |
index d9a0f53..1650489 100644 | |
--- a/bears/python/YapfBear.py | |
+++ b/bears/python/YapfBear.py | |
@@ -72,17 +72,17 @@ class YapfBear(LocalBear): | |
``` | |
call_func_that_takes_a_dict( | |
- { | |
- 'key1': 'value1', | |
- 'key2': 'value2', | |
- } | |
+ { | |
+ 'key1': 'value1', | |
+ 'key2': 'value2', | |
+ } | |
) | |
``` | |
would reformat to: | |
``` | |
call_func_that_takes_a_dict({ | |
- 'key1': 'value1', | |
- 'key2': 'value2', | |
+ 'key1': 'value1', | |
+ 'key2': 'value2', | |
}) | |
``` | |
:param join_multiple_lines: | |
@@ -123,27 +123,26 @@ class YapfBear(LocalBear): | |
return | |
options = """ | |
-[style] | |
-indent_width = {indent_size} | |
-column_limit = {max_line_length} | |
-allow_multiline_lambdas = {allow_multiline_lambdas} | |
-continuation_indent_width = {continuation_tab_width} | |
-dedent_closing_brackets = {dedent_closing_brackets} | |
-indent_dictionary_value = {indent_dictionary_value} | |
-join_multiple_lines = {join_multiple_lines} | |
-spaces_around_power_operator = {spaces_around_power_operator} | |
-spaces_before_comment = {spaces_before_comment} | |
-coalesce_brackets = {coalesce_brackets} | |
-split_before_bitwise_operator = {split_before_bitwise_operator} | |
-split_before_first_argument = {split_before_first_argument} | |
-split_before_logical_operator = {split_before_logical_operator} | |
-split_before_named_assigns = {split_before_named_assigns} | |
-based_on_style = {based_on_style} | |
-blank_line_before_nested_class_or_def = {blank_line_before_nested_class_or_def} | |
-split_arguments_when_comma_terminated = {split_arguments_when_comma_terminated} | |
-space_between_ending_comma_and_closing_bracket= \ | |
-{space_between_ending_comma_and_closing_bracket} | |
-""" | |
+ options = dent_size} | |
+ options = x_line_length} | |
+ options = mbdas = {allow_multiline_lambdas} | |
+ options = t_width = {continuation_tab_width} | |
+ options = ckets = {dedent_closing_brackets} | |
+ options = value = {indent_dictionary_value} | |
+ options = s = {join_multiple_lines} | |
+ options = r_operator = {spaces_around_power_operator} | |
+ options = ent = {spaces_before_comment} | |
+ options = = {coalesce_brackets} | |
+ options = se_operator = {split_before_bitwise_operator} | |
+ options = _argument = {split_before_first_argument} | |
+ options = al_operator = {split_before_logical_operator} | |
+ options = _assigns = {split_before_named_assigns} | |
+ options = based_on_style} | |
+ options = nested_class_or_def = {blank_line_before_nested_class_or_def} | |
+ options = en_comma_terminated = {split_arguments_when_comma_terminated} | |
+ options = ng_comma_and_closing_bracket= \ | |
+ options = ing_comma_and_closing_bracket} | |
+ options = """ | |
options += 'use_tabs = ' + str(not use_spaces) + '\n' | |
options += ('split_penalty_after_opening_bracket = ' + | |
('30' if prefer_line_break_after_opening_bracket | |
diff --git a/bears/python/requirements/PinRequirementsBear.py b/bears/python/requirements/PinRequirementsBear.py | |
index 24e8b3f..b330072 100644 | |
--- a/bears/python/requirements/PinRequirementsBear.py | |
+++ b/bears/python/requirements/PinRequirementsBear.py | |
@@ -21,7 +21,8 @@ class PinRequirementsBear(LocalBear): | |
issue if the minor version is not given. If you do not wish that, do | |
not use this bear. | |
- :param require_patch: Requires a patch version specified if True. | |
+ :param require_patch: | |
+ Requires a patch version specified if True. | |
""" | |
for i, line in enumerate(file, start=1): | |
match = re.search(r'[=<>]+([0-9.]+)(?:$|\s|#)', line) | |
diff --git a/bears/python/requirements/PySafetyBear.py b/bears/python/requirements/PySafetyBear.py | |
index 86632cd..6ed0075 100644 | |
--- a/bears/python/requirements/PySafetyBear.py | |
+++ b/bears/python/requirements/PySafetyBear.py | |
@@ -86,7 +86,8 @@ class PySafetyBear(LocalBear): | |
""" | |
Yields all package requirements parseable from the given lines. | |
- :param lines: An iterable of lines from a requirements file. | |
+ :param lines: | |
+ An iterable of lines from a requirements file. | |
""" | |
for line in lines: | |
try: | |
diff --git a/bears/r/FormatRBear.py b/bears/r/FormatRBear.py | |
index e0ba3d1..7b98a36 100644 | |
--- a/bears/r/FormatRBear.py | |
+++ b/bears/r/FormatRBear.py | |
@@ -74,7 +74,7 @@ class FormatRBear: | |
changes to | |
``` | |
1 + 1 + 1 + 1 + 1 + 1 + | |
- 1 | |
+ 1 | |
``` | |
""" | |
options = {'source="' + escape(filename, '"\\') + '"', | |
diff --git a/bears/ruby/RuboCopBear.py b/bears/ruby/RuboCopBear.py | |
index 877506d..c47decb 100644 | |
--- a/bears/ruby/RuboCopBear.py | |
+++ b/bears/ruby/RuboCopBear.py | |
@@ -89,9 +89,9 @@ class RuboCopBear: | |
:param access_modifier_indentation: | |
Indent private/protected/public as deep as method definitions | |
options: | |
- ``indent`` : Indent modifiers like class members. | |
- ``outdent`` : Indent modifiers one level less than | |
- class members. | |
+ ``indent`` : Indent modifiers like class members. | |
+ ``outdent`` : Indent modifiers one level less than | |
+ class members. | |
:param preferred_alias: | |
Which method to use for aliasing in ruby. | |
options : ``alias`` , ``alias_method``. | |
@@ -103,19 +103,19 @@ class RuboCopBear: | |
Select whether hashes that are the last argument in a method call | |
should be inspected. | |
options: ``always_inspect``, ``always_ignore``, | |
- ``ignore_implicit``, ``ignore_explicit``. | |
+ ``ignore_implicit``, ``ignore_explicit``. | |
:param align_parameters: | |
Alignment of parameters in multi-line method calls. | |
options: | |
- ``with_first_parameter``: Aligns the following lines | |
- along the same column as the | |
- first parameter. | |
+ ``with_first_parameter``: Aligns the following lines | |
+ along the same column as the | |
+ first parameter. | |
- ``with_fixed_indentation``: Aligns the following lines with one | |
- level of indentation relative to | |
- the start of the line with the | |
- method call. | |
+ ``with_fixed_indentation``: Aligns the following lines with one | |
+ level of indentation relative to | |
+ the start of the line with the | |
+ method call. | |
:param class_check: | |
How to check type of class. | |
options: ``is_a?``, ``kind_of?``. | |
diff --git a/bears/scala/ScalaLintBear.py b/bears/scala/ScalaLintBear.py | |
index 86c32c7..dcf9841 100644 | |
--- a/bears/scala/ScalaLintBear.py | |
+++ b/bears/scala/ScalaLintBear.py | |
@@ -37,7 +37,8 @@ class ScalaLintBear: | |
def create_arguments(filename, file, config_file, | |
scalalint_config: str=scalastyle_config_file): | |
""" | |
- :param scalalint_config: Path to a custom configuration file. | |
+ :param scalalint_config: | |
+ Path to a custom configuration file. | |
""" | |
return ('-jar', ScalaLintBear.jar, filename, '--config', | |
scalalint_config) | |
diff --git a/bears/scss/SCSSLintBear.py b/bears/scss/SCSSLintBear.py | |
index 3231a7f..3b9fd5e 100644 | |
--- a/bears/scss/SCSSLintBear.py | |
+++ b/bears/scss/SCSSLintBear.py | |
@@ -184,18 +184,18 @@ class SCSSLintBear: | |
variable declarations. | |
:: | |
- div { | |
- width: 100px; | |
- } | |
+ div { | |
+ width: 100px; | |
+ } | |
Is not valid, whereas | |
:: | |
- $column-width: 100px; | |
+ $column-width: 100px; | |
- div { | |
- width: $column-width; | |
- } | |
+ div { | |
+ width: $column-width; | |
+ } | |
is valid. | |
:param check_properties_spelling: | |
Reports when an unknown or disabled CSS property is used | |
@@ -210,14 +210,13 @@ class SCSSLintBear: | |
and ``:first-child``, should be declared with one colon. | |
:: | |
- p::before { | |
- content: '>' | |
- } | |
- | |
- p:hover { | |
- color: red; | |
- } | |
+ p::before { | |
+ content: '>' | |
+ } | |
+ p:hover { | |
+ color: red; | |
+ } | |
:param spaces_between_parentheses: | |
Spaces to require between parentheses. | |
:param spaces_around_operators: | |
diff --git a/bears/shell/ShellCheckBear.py b/bears/shell/ShellCheckBear.py | |
index d697061..c8606d2 100644 | |
--- a/bears/shell/ShellCheckBear.py | |
+++ b/bears/shell/ShellCheckBear.py | |
@@ -22,6 +22,7 @@ class ShellCheckBear: | |
@staticmethod | |
def create_arguments(filename, file, config_file, shell: str='sh'): | |
""" | |
- :param shell: Target shell being used. | |
+ :param shell: | |
+ Target shell being used. | |
""" | |
return '--f', 'gcc', '-s', shell, filename | |
diff --git a/bears/swift/TailorBear.py b/bears/swift/TailorBear.py | |
index c328b3f..8638b40 100644 | |
--- a/bears/swift/TailorBear.py | |
+++ b/bears/swift/TailorBear.py | |
@@ -58,20 +58,29 @@ class TailorBear: | |
Bear configuration arguments. | |
Using '0' will disable the check. | |
- :param max_line_length: maximum number of characters in a Line | |
- <0-999>. | |
- :param max_class_length: maximum number of lines in a Class <0-999>. | |
- :param max_closure_length: maximum number of lines in a Closure | |
- <0-999>. | |
- :param max_file_length: maximum number of lines in a File <0-999>. | |
- :param max_function_length: maximum number of lines in a Function | |
- <0-999>. | |
- :param max_name_length: maximum length of Identifier name <0-999>. | |
- :param max_struct_length: maximum number od lines in a Struct | |
- <0-999>. | |
- :param min_name_length: minimum number of characters in Identifier | |
- name <1-999>. | |
- :param tailor_config: path to Tailor configuration file. | |
+ :param max_line_length: | |
+ maximum number of characters in a Line | |
+ <0-999>. | |
+ :param max_class_length: | |
+ maximum number of lines in a Class <0-999>. | |
+ :param max_closure_length: | |
+ maximum number of lines in a Closure | |
+ <0-999>. | |
+ :param max_file_length: | |
+ maximum number of lines in a File <0-999>. | |
+ :param max_function_length: | |
+ maximum number of lines in a Function | |
+ <0-999>. | |
+ :param max_name_length: | |
+ maximum length of Identifier name <0-999>. | |
+ :param max_struct_length: | |
+ maximum number od lines in a Struct | |
+ <0-999>. | |
+ :param min_name_length: | |
+ minimum number of characters in Identifier | |
+ name <1-999>. | |
+ :param tailor_config: | |
+ path to Tailor configuration file. | |
""" | |
args = ('--format=json', | |
'--max-line-length', str(max_line_length), | |
diff --git a/bears/typescript/TSLintBear.py b/bears/typescript/TSLintBear.py | |
index 4ec1cd1..c474cbb 100644 | |
--- a/bears/typescript/TSLintBear.py | |
+++ b/bears/typescript/TSLintBear.py | |
@@ -29,8 +29,10 @@ class TSLintBear: | |
def create_arguments(filename, file, config_file, | |
tslint_config: path='', rules_dir: path=''): | |
""" | |
- :param tslint_config: Path to configuration file. | |
- :param rules_dir: Rules directory | |
+ :param tslint_config: | |
+ Path to configuration file. | |
+ :param rules_dir: | |
+ Rules directory | |
""" | |
args = ('--format', 'json') | |
if tslint_config: | |
diff --git a/bears/vcs/git/GitCommitBear.py b/bears/vcs/git/GitCommitBear.py | |
index 5aaa844..c7a01e4 100644 | |
--- a/bears/vcs/git/GitCommitBear.py | |
+++ b/bears/vcs/git/GitCommitBear.py | |
@@ -92,8 +92,9 @@ class GitCommitBear(GlobalBear): | |
This bear ensures automatically that the shortlog and body do not | |
exceed a given line-length and that a newline lies between them. | |
- :param allow_empty_commit_message: Whether empty commit messages are | |
- allowed or not. | |
+ :param allow_empty_commit_message: | |
+ Whether empty commit messages are | |
+ allowed or not. | |
""" | |
with change_directory(self.get_config_dir() or os.getcwd()): | |
stdout, stderr = run_shell_command('git log -1 --pretty=%B') | |
@@ -131,16 +132,21 @@ class GitCommitBear(GlobalBear): | |
""" | |
Checks the given shortlog. | |
- :param shortlog: The shortlog message string. | |
- :param shortlog_length: The maximum length of the shortlog. | |
- The newline character at end does not | |
- count to the length. | |
- :param shortlog_regex: A regex to check the shortlog with. | |
- :param shortlog_trailing_period: Whether a dot shall be enforced at end | |
- end or not (or ``None`` for "don't | |
- care"). | |
- :param shortlog_wip_check: Whether a "WIP" in the shortlog text | |
- should yield a result or not. | |
+ :param shortlog: | |
+ The shortlog message string. | |
+ :param shortlog_length: | |
+ The maximum length of the shortlog. | |
+ The newline character at end does not | |
+ count to the length. | |
+ :param shortlog_regex: | |
+ A regex to check the shortlog with. | |
+ :param shortlog_trailing_period: | |
+ Whether a dot shall be enforced at end | |
+ end or not (or ``None`` for "don't | |
+ care"). | |
+ :param shortlog_wip_check: | |
+ Whether a "WIP" in the shortlog text | |
+ should yield a result or not. | |
""" | |
diff = len(shortlog) - shortlog_length | |
if diff > 0: | |
@@ -221,15 +227,20 @@ class GitCommitBear(GlobalBear): | |
""" | |
Checks the given commit body. | |
- :param body: The body of the commit message of HEAD. | |
- :param body_line_length: The maximum line-length of the body. The | |
- newline character at each line end does not | |
- count to the length. | |
- :param force_body: Whether a body shall exist or not. | |
- :param ignore_length_regex: Lines matching each of the regular | |
- expressions in this list will be ignored. | |
- :param body_regex: If provided, checks the presence of regex | |
- in the commit body. | |
+ :param body: | |
+ The body of the commit message of HEAD. | |
+ :param body_line_length: | |
+ The maximum line-length of the body. The | |
+ newline character at each line end does not | |
+ count to the length. | |
+ :param force_body: | |
+ Whether a body shall exist or not. | |
+ :param ignore_length_regex: | |
+ Lines matching each of the regular | |
+ expressions in this list will be ignored. | |
+ :param body_regex: | |
+ If provided, checks the presence of regex | |
+ in the commit body. | |
""" | |
if len(body) == 0: | |
if force_body: | |
diff --git a/bears/xml2/XMLBear.py b/bears/xml2/XMLBear.py | |
index 99cad68..f935272 100644 | |
--- a/bears/xml2/XMLBear.py | |
+++ b/bears/xml2/XMLBear.py | |
@@ -12,8 +12,10 @@ def path_or_url(xml_dtd): | |
""" | |
Converts the setting value to url or path. | |
- :param xml_dtd: Setting key. | |
- :return: Returns a converted setting value. | |
+ :param xml_dtd: | |
+ Setting key. | |
+ :return: | |
+ Returns a converted setting value. | |
""" | |
try: | |
return url(xml_dtd) | |
@@ -46,9 +48,11 @@ class XMLBear: | |
xml_schema: path='', | |
xml_dtd: path_or_url=''): | |
""" | |
- :param xml_schema: ``W3C XML Schema`` file used for validation. | |
- :param xml_dtd: ``Document type Definition (DTD)`` file or | |
- url used for validation. | |
+ :param xml_schema: | |
+ ``W3C XML Schema`` file used for validation. | |
+ :param xml_dtd: | |
+ ``Document type Definition (DTD)`` file or | |
+ url used for validation. | |
""" | |
args = (filename,) | |
if xml_schema: | |
diff --git a/bears/yaml/YAMLLintBear.py b/bears/yaml/YAMLLintBear.py | |
index 0a1f017..c2f01b6 100644 | |
--- a/bears/yaml/YAMLLintBear.py | |
+++ b/bears/yaml/YAMLLintBear.py | |
@@ -43,7 +43,8 @@ class YAMLLintBear: | |
@staticmethod | |
def create_arguments(filename, file, config_file, yamllint_config: str=''): | |
""" | |
- :param yamllint_config: Path to a custom configuration file. | |
+ :param yamllint_config: | |
+ Path to a custom configuration file. | |
""" | |
args = ('-f', 'parsable', filename) | |
if yamllint_config: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment