Showing 17 of 29 total issues
File glossary.py
has 350 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Checker for glossary usage."""
import re
from padpo.checkers.baseclass import Checker
Function check_item
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_item(self, item: PoItem):
"""Check an item in a `*.po` file."""
if not item.msgstr_full_content:
return # no warning
original_content = item.msgid_rst2txt.lower()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function main
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def main():
"""Entry point."""
global log
parser = argparse.ArgumentParser(description="Linter for *.po files.")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function tag_in_pull_request
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def tag_in_pull_request(self, pull_request_info):
"""Tag items being part of the pull request."""
if not pull_request_info:
for item in self.content:
item.inside_pull_request = True
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function lines_in_diff
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def lines_in_diff(diff):
"""Yield line numbers modified in a diff (new line numbers)."""
for line in diff.splitlines():
if line.startswith("@@"):
match = re.search(r"@@\s*\-\d+,\d+\s+\+(\d+),(\d+)\s+@@", line)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function display_warnings
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def display_warnings(self, pull_request_info=None):
"""Log warnings and errors, return errors and warnings lists."""
self.tag_in_pull_request(pull_request_info)
errors = []
warnings = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parse_file
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_file(self, path):
"""Parse a `*.po` file according to its path."""
# TODO assert path is a file, not a dir
item = None
with open(path, encoding="utf8") as f:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function check_item
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_item(self, item: PoItem):
"""Check an item in a `*.po` file."""
text = item.msgstr_rst2txt
for match in re.finditer(r"(.{0,30})(«[^ ])(.{0,30})", text):
self.__add_message(item, *match.groups())
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __add_message_space_before
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __add_message_space_before(self, item, prefix, match, suffix):
Function append_line
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def append_line(self, line):
"""Append a line of a `*.po` file to the item."""
self.lineno_end += 1
if line.startswith("msgid"):
self.parsing_msgid = True
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function filter_out_grammar_error
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def filter_out_grammar_error(self, warning: GrammalecteMessage) -> bool:
"""Return True when grammalecte error should be ignored."""
if not isinstance(warning, GrammalecteGrammarMessage):
return False
if warning.rule in (
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return False
Function filter_out_spelling_error
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def filter_out_spelling_error(self, warning: GrammalecteMessage) -> bool:
"""Return True when grammalecte error should be ignored."""
if not isinstance(warning, GrammalecteSpellingMessage):
return False
if set(warning.word) == {"x"}:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"