Showing 104 of 104 total issues

Function show has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def show():
    """Get all markdown files from 'content/news/', parse them and put
    them in a list for the template.
    The formatting of these files is described in the readme.
    """
Severity: Minor
Found in sipa/blueprints/news.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 index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def index():
    """Usersuite landing page with user account information
    and traffic overview.
    """
    info = current_user.finance_information
Severity: Minor
Found in sipa/blueprints/usersuite.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 activate_network_access has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def activate_network_access():
    """As user, activate your network access
    """

    capability_or_403('network_access_active', 'edit')
Severity: Minor
Found in sipa/blueprints/usersuite.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in sipa/backends/datasource.py - About 50 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    @pytest.mark.parametrize("num", (-3, -5, -1.6, -7.4, -0.5))
    def test_negative_style_returned(num):
        assert money_style(num) == STYLE_NEG
    Severity: Minor
    Found in tests/test_units.py and 1 other location - About 50 mins to fix
    tests/test_units.py on lines 85..87

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 36.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    @pytest.mark.parametrize("num", (3, 5, 1.6, 7.4, 0))
    def test_positive_style_returned(num):
        assert money_style(num) == STYLE_POS
    Severity: Minor
    Found in tests/test_units.py and 1 other location - About 50 mins to fix
    tests/test_units.py on lines 90..92

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 36.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    def hosting(action=None):
        """Change various settings for Helios.
        """
        if not current_user.has_property("userdb"):
            abort(403)
    Severity: Minor
    Found in sipa/blueprints/usersuite.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 change_mail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def change_mail():
        """Frontend page to change the user's mail address"""
    
        capability_or_403('mail', 'edit')
    
    
    Severity: Minor
    Found in sipa/blueprints/usersuite.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 continue_membership has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def continue_membership():
        """
        Cancel termination of membership
        :return:
        """
    Severity: Minor
    Found in sipa/blueprints/usersuite.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 request_password_reset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def request_password_reset():
        user_id = None
    
        ip_user = backends.user_from_ip(request.remote_addr)
        if ip_user.is_authenticated:
    Severity: Minor
    Found in sipa/blueprints/generic.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, parent, blocks):
            """ Parse a table block and build table. """
            block = blocks.pop(0).split('\n')
            header = block[0].strip()
            seperator = block[1].strip()
    Severity: Minor
    Found in sipa/utils/bootstraped_tables.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 send_complex_mail has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def send_complex_mail(subject: str, message: str, tag: str = "",
    Severity: Minor
    Found in sipa/mail.py - About 45 mins to fix

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

          def activate_network_access(self, password, mac, birthdate, host_name):
      Severity: Minor
      Found in sipa/model/user.py - About 35 mins to fix

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

        def send_contact_mail(author: str, subject: str, message: str,
        Severity: Minor
        Found in sipa/mail.py - About 35 mins to fix

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

              def change_mac(self, user_id, password, interface_id, new_mac, host_name):
          Severity: Minor
          Found in sipa/model/pycroft/api.py - About 35 mins to fix

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

                def assert_url_response_code(
            Severity: Minor
            Found in tests/assertions.py - About 35 mins to fix

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

              def send_usersuite_contact_mail(subject: str, message: str, category: str,
              Severity: Minor
              Found in sipa/mail.py - About 35 mins to fix

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

                    def match_person(self, first_name: str, last_name: str, birthdate: date, tenant_number: int,
                Severity: Minor
                Found in sipa/model/pycroft/api.py - About 35 mins to fix

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

                  def send_mail(author: str, recipient: str, subject: str, message: str,
                  Severity: Minor
                  Found in sipa/mail.py - About 35 mins to fix

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

                        def activate_network_access(self, user_id, password, mac, birthdate, host_name):
                    Severity: Minor
                    Found in sipa/model/pycroft/api.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language