report_docx/report/report_helper.py
Function calc_length
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def calc_length(s):
"""
把字符串,数字类型的参数转化为docx的长度对象,如:
12 => Pt(12)
'12' => Pt(12)
- 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 picture
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def picture(ctx, data, width=None, height=None, align=None):
Avoid too many return
statements within this function. Open
Open
return docx.shared.Twips(float(s[:-5]))
Avoid too many return
statements within this function. Open
Open
return docx.shared.Emu(float(s[:-3]))
Avoid too many return
statements within this function. Open
Open
return docx.shared.Pt(float(s))
Avoid too many return
statements within this function. Open
Open
return docx.shared.Pt(float(s[:-2]))
Trailing whitespace Open
Open
创建一个jinja的enviroment,然后添加一个过滤器
- Read upRead up
- Exclude checks
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