CiscoUcs/imcsdk

View on GitHub
imcsdk/apis/server/bios.py

Summary

Maintainability
F
6 days
Test Coverage

File bios.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2016 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Minor
Found in imcsdk/apis/server/bios.py - About 3 hrs to fix

    Function bios_tokens_exist has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def bios_tokens_exist(handle, tokens={}, server_id=1):
        """
        Args:
            handle (ImcHandle)
            tokens (dictionary) : (key, value) pair of bios tokens with key being the name of the token
    Severity: Minor
    Found in imcsdk/apis/server/bios.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 bios_profile_upload has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def bios_profile_upload(handle, remote_server, remote_file, protocol='tftp',
    Severity: Major
    Found in imcsdk/apis/server/bios.py - About 1 hr to fix

      Function bios_profile_activate has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def bios_profile_activate(handle, name, backup_on_activate=True,
      Severity: Minor
      Found in imcsdk/apis/server/bios.py - About 45 mins to fix

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

        def bios_profile_generate_json(handle, name, server_id=1, file_name=None):
            """
            Generates a json output of the bios profile specified by the name on
            the Cisco IMC server.
            If a file name is specified, it writes the output to the file.
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 1 day to fix
        imcsdk/apis/v2/server/bios.py on lines 285..323

        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 152.

        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

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

        def bios_profile_exists(handle, name, server_id=1, **kwargs):
            """
            Checks if the bios profile with the specified params exists
        
            Args:
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 1 day to fix
        imcsdk/apis/v2/server/bios.py on lines 247..282

        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 131.

        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

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

        def bios_profile_activate(handle, name, backup_on_activate=True,
                                  reboot_on_activate=False, server_id=1, **kwargs):
            """
            Activates the bios profile specified by name on the Cisco IMC Server
        
        
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 6 hrs to fix
        imcsdk/apis/v2/server/bios.py on lines 153..194

        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 109.

        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

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

        def bios_profile_upload(handle, remote_server, remote_file, protocol='tftp',
                                user=None, pwd=None, server_id=1, **kwargs):
            """
            Uploads a user configured bios profile in json format.
            Cisco IMC supports uploading a maximum of 3 profiles
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 6 hrs to fix
        imcsdk/apis/v2/server/bios.py on lines 87..126

        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 108.

        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

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

        def _get_bios_profile_mo(handle, name, server_id=1):
            bios_dn = _get_bios_dn(handle, server_id)
            parent_dn = bios_dn + '/profile-mgmt'
            mos = handle.query_children(in_dn=parent_dn)
            for mo in mos:
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 4 hrs to fix
        imcsdk/apis/v2/server/bios.py on lines 34..41

        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 81.

        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

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

        def bios_profile_backup_running(handle, server_id=1, **kwargs):
            """
            Backups up the running configuration of various bios tokens to create a
            'cisco_backup_profile'.
            Will overwrite the existing backup profile if it exists.
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 4 hrs to fix
        imcsdk/apis/v2/server/bios.py on lines 52..83

        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 75.

        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

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

        def _get_bios_profile(handle, name, server_id=1):
            mo = _get_bios_profile_mo(handle, name=name, server_id=server_id)
            if mo is None:
                raise ImcOperationError("Get BiosProfile: %s " % name,
                                        "Managed Object not found")
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 2 hrs to fix
        imcsdk/apis/v2/server/bios.py on lines 44..49

        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 53.

        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

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

        def bios_profile_delete(handle, name, server_id=1):
            """
            Deletes the bios profile specified by the name on the Cisco IMC server
        
            Args:
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 2 hrs to fix
        imcsdk/apis/v2/server/bios.py on lines 197..220

        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 50.

        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

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

        def is_bios_profile_enabled(handle, name, server_id=1):
            """
            Args:
                handle (ImcHandle)
                name (str): Name of the bios profile.
        Severity: Major
        Found in imcsdk/apis/server/bios.py and 1 other location - About 1 hr to fix
        imcsdk/apis/v2/server/bios.py on lines 223..244

        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 47.

        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

        There are no issues that match your filters.

        Category
        Status