osbzr/gooderp_addons

View on GitHub
report_docx/report/report_helper.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function calc_length has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def calc_length(s):
    """
    把字符串,数字类型的参数转化为docx的长度对象,如:
    12 => Pt(12)
    '12' => Pt(12)
Severity: Minor
Found in report_docx/report/report_helper.py - About 55 mins to fix

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 picture has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def picture(ctx, data, width=None, height=None, align=None):
Severity: Minor
Found in report_docx/report/report_helper.py - About 35 mins to fix

    Avoid too many return statements within this function.
    Open

            return docx.shared.Twips(float(s[:-5]))
    Severity: Major
    Found in report_docx/report/report_helper.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return docx.shared.Emu(float(s[:-3]))
      Severity: Major
      Found in report_docx/report/report_helper.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return docx.shared.Pt(float(s))
        Severity: Major
        Found in report_docx/report/report_helper.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return docx.shared.Pt(float(s[:-2]))
          Severity: Major
          Found in report_docx/report/report_helper.py - About 30 mins to fix

            Trailing whitespace
            Open

                创建一个jinja的enviroment,然后添加一个过滤器 
            Severity: Minor
            Found in report_docx/report/report_helper.py by pep8

            Trailing whitespace is superfluous.

            The warning returned varies on whether the line itself is blank,
            for easier filtering for those who want to indent their blank lines.
            
            Okay: spam(1)\n#
            W291: spam(1) \n#
            W293: class Foo(object):\n    \n    bang = 12

            There are no issues that match your filters.

            Category
            Status