Shoobx/shoobx.rml2odt

View on GitHub
src/shoobx/rml2odt/stylesheet.py

Summary

Maintainability
D
3 days
Test Coverage

File stylesheet.py has 536 lines of code (exceeds 250 allowed). Consider refactoring.
Open

##############################################################################
#
# Copyright (c) 2017 Shoobx, Inc.
# All Rights Reserved.
#
Severity: Major
Found in src/shoobx/rml2odt/stylesheet.py - About 1 day to fix

    Function registerListStyle has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def registerListStyle(doc, name, rmlStyle, attributes=None, ulol=None):
        """Registers an rmlStyle as ODF styles
    
        rmlStyles have information both for ordered and unordered lists,
        ODF styles do not, so we need to register two different, but similar lists.
    Severity: Minor
    Found in src/shoobx/rml2odt/stylesheet.py - About 5 hrs 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 registerParagraphStyle has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def registerParagraphStyle(doc, name, rmlStyle):
        if 'style.' in name:
            name = name[6:]
    
        odtStyle = odf.style.Style(name=name, family='paragraph')
    Severity: Minor
    Found in src/shoobx/rml2odt/stylesheet.py - About 3 hrs 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 convertLineStyle has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def convertLineStyle(attrs):
        # ODT line styles discovered by trying:
        # solid, dotted, dashed, fine-dashed, dash-dot, dash-dot-dot,
        # double, double-thin
        # there are plenty left
    Severity: Minor
    Found in src/shoobx/rml2odt/stylesheet.py - About 3 hrs 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 adjustAttributeValues has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def adjustAttributeValues(self, style, parentName):
            try:
                parentElem = self.parent.parent.document.getStyleByName(
                    str(parentName))
            except AssertionError:
    Severity: Minor
    Found in src/shoobx/rml2odt/stylesheet.py - About 1 hr 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 registerParagraphStyle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def registerParagraphStyle(doc, name, rmlStyle):
        if 'style.' in name:
            name = name[6:]
    
        odtStyle = odf.style.Style(name=name, family='paragraph')
    Severity: Minor
    Found in src/shoobx/rml2odt/stylesheet.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          if dash[0] in (1, 2):
                              style = 'dotted'
                          elif dash[0] in (3, 4):
                              style = 'fine-dashed'
                          else:
      Severity: Major
      Found in src/shoobx/rml2odt/stylesheet.py - About 45 mins to fix

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

        def registerListStyle(doc, name, rmlStyle, attributes=None, ulol=None):
        Severity: Minor
        Found in src/shoobx/rml2odt/stylesheet.py - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status