osbzr/gooderp_addons

View on GitHub
report_docx/report/report_docx.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function __str__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __str__(self):
        '''支持直接在word 上写 many2one 字段'''
        name = ''
        if self.data and self.data.display_name:
            name = self.data.display_name
Severity: Minor
Found in report_docx/report/report_docx.py - About 45 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 create has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create(self, cr, uid, ids, data, context=None):
Severity: Minor
Found in report_docx/report/report_docx.py - About 35 mins to fix

    Function create_source_docx has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def create_source_docx(self, cr, uid, ids, report, context=None):
    Severity: Minor
    Found in report_docx/report/report_docx.py - About 35 mins to fix

      Function get_docx_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_docx_data(self, cr, uid, ids, report, context):
      Severity: Minor
      Found in report_docx/report/report_docx.py - About 35 mins to fix

        Function _compute_by_selection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _compute_by_selection(self, field, temp):
                if field and field.type == 'selection':
                    selection = field.selection
                    if isinstance(selection, basestring):
                        selection = getattr(self.data, selection)()
        Severity: Minor
        Found in report_docx/report/report_docx.py - About 35 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 _compute_temp_false has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _compute_temp_false(self, field, temp):
                if not temp:
                    if field and field.type in ('integer', 'float'):
                        return 0
                if field.type == 'float' and int(temp) == temp:
        Severity: Minor
        Found in report_docx/report/report_docx.py - About 25 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

        Module level import not at top of file
        Open

        from odoo import models
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        Line too long (87 > 79 characters)
        Open

                    temp = temp.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Module level import not at top of file
        Open

        from odoo import fields
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        Line too long (84 > 79 characters)
        Open

                        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Module level import not at top of file
        Open

        import pytz
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        Module level import not at top of file
        Open

        import os
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        Line too long (85 > 79 characters)
        Open

                if isinstance(temp, unicode) and ('&' in temp or '<' in temp or '>' in temp):
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (104 > 79 characters)
        Open

                message = str((datetime.now()).strftime('%Y-%m-%d %H:%M:%S')) + ' ' + env.user.name + u' 打印了该单据'
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Module level import not at top of file
        Open

        from odoo import api
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        Line too long (80 > 79 characters)
        Open

                    return self.create_source_docx(cr, uid, ids, report_ids[0], context)
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Module level import not at top of file
        Open

        import tempfile
        Severity: Minor
        Found in report_docx/report/report_docx.py by pep8

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        There are no issues that match your filters.

        Category
        Status