CiscoUcs/imcsdk

View on GitHub
imcsdk/imccoremeta.py

Summary

Maintainability
F
5 days
Test Coverage

File imccoremeta.py has 473 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2015 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/imccoremeta.py - About 7 hrs to fix

    Function validate_property_value has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_property_value(self, input_value):
            """validate property value of mo."""
            error_msg = None
    
            if input_value is None:
    Severity: Minor
    Found in imcsdk/imccoremeta.py - About 6 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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, name, xml_attribute, rn, version, inp_out, mask,
    Severity: Major
    Found in imcsdk/imccoremeta.py - About 1 hr to fix

      Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, name, xml_attribute, field_type, version, access, mask,
      Severity: Major
      Found in imcsdk/imccoremeta.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if self.__spin is not None and self.__patch is None:
                    self.__patch = 'z'
                elif self.__patch is not None and self.__mr is not None and self.__patch.isdigit() and self.__mr.isdigit():
                    log.debug("Interim version encountered: %s. MR version has been bumped up." % self.version)
                    self.__mr = str(int(self.__mr) + 1)
        Severity: Major
        Found in imcsdk/imccoremeta.py - About 1 hr to fix

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

              def __init__(self, version):
                  if version is None:
                      return None
          
                  self.__version = version
          Severity: Minor
          Found in imcsdk/imccoremeta.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, name, xml_attribute, field_type, version, inp_out,
          Severity: Minor
          Found in imcsdk/imccoremeta.py - About 45 mins to fix

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

                def __init__(self, min_length=None, max_length=None, pattern=None,
            Severity: Minor
            Found in imcsdk/imccoremeta.py - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                          return
              Severity: Major
              Found in imcsdk/imccoremeta.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return
                Severity: Major
                Found in imcsdk/imccoremeta.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return
                  Severity: Major
                  Found in imcsdk/imccoremeta.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return True, error_msg
                    Severity: Major
                    Found in imcsdk/imccoremeta.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return False, error_msg
                      Severity: Major
                      Found in imcsdk/imccoremeta.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return True, error_msg
                        Severity: Major
                        Found in imcsdk/imccoremeta.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return True, error_msg
                          Severity: Major
                          Found in imcsdk/imccoremeta.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return
                            Severity: Major
                            Found in imcsdk/imccoremeta.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return True, error_msg
                              Severity: Major
                              Found in imcsdk/imccoremeta.py - About 30 mins to fix

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

                                        out_str += ("-" * len("Property")).ljust(ts * 4) + "-" * len(
                                            self.name) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 1 other location - About 2 hrs to fix
                                imcsdk/imccoreutils.py on lines 585..586

                                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

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

                                        out_str += str("min_length").ljust(ts * 4) + ':' + str(
                                            self.restriction.min_length) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 3 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 430..431
                                imcsdk/imccoremeta.py on lines 432..433
                                imcsdk/imccoremeta.py on lines 434..435

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

                                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 4 locations. Consider refactoring.
                                Open

                                        out_str += str("pattern").ljust(ts * 4) + ':' + str(
                                            self.restriction.pattern) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 3 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 428..429
                                imcsdk/imccoremeta.py on lines 430..431
                                imcsdk/imccoremeta.py on lines 434..435

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

                                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 4 locations. Consider refactoring.
                                Open

                                        out_str += str("max_length").ljust(ts * 4) + ':' + str(
                                            self.restriction.max_length) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 3 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 428..429
                                imcsdk/imccoremeta.py on lines 432..433
                                imcsdk/imccoremeta.py on lines 434..435

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

                                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 4 locations. Consider refactoring.
                                Open

                                        out_str += str("value_set").ljust(ts * 4) + ':' + str(
                                            self.restriction.value_set) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 3 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 428..429
                                imcsdk/imccoremeta.py on lines 430..431
                                imcsdk/imccoremeta.py on lines 432..433

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

                                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 9 locations. Consider refactoring.
                                Open

                                        out_str += str("field_type").ljust(ts * 4) + ':' + str(
                                            self.field_type) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 8 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 420..421
                                imcsdk/imccoremeta.py on lines 424..425
                                imcsdk/imccoreutils.py on lines 587..588
                                imcsdk/imccoreutils.py on lines 589..590
                                imcsdk/imccoreutils.py on lines 591..592
                                imcsdk/imccoreutils.py on lines 593..593
                                imcsdk/imccoreutils.py on lines 594..595
                                imcsdk/imccoreutils.py on lines 596..596

                                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

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

                                        out_str += str("xml_attribute").ljust(ts * 4) + ':' + str(
                                            self.xml_attribute) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 8 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 422..423
                                imcsdk/imccoremeta.py on lines 424..425
                                imcsdk/imccoreutils.py on lines 587..588
                                imcsdk/imccoreutils.py on lines 589..590
                                imcsdk/imccoreutils.py on lines 591..592
                                imcsdk/imccoreutils.py on lines 593..593
                                imcsdk/imccoreutils.py on lines 594..595
                                imcsdk/imccoreutils.py on lines 596..596

                                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

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

                                        out_str += str("min_version").ljust(ts * 4) + ':' + str(
                                            self.version) + "\n"
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 8 other locations - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 420..421
                                imcsdk/imccoremeta.py on lines 422..423
                                imcsdk/imccoreutils.py on lines 587..588
                                imcsdk/imccoreutils.py on lines 589..590
                                imcsdk/imccoreutils.py on lines 591..592
                                imcsdk/imccoreutils.py on lines 593..593
                                imcsdk/imccoreutils.py on lines 594..595
                                imcsdk/imccoreutils.py on lines 596..596

                                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

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

                                    def __init__(self, name, xml_attribute, field_type, version, inp_out,
                                                 is_complex_type):
                                        self.__name = name
                                        self.__xml_attribute = xml_attribute
                                        self.__field_type = field_type
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 1 other location - About 1 hr to fix
                                imcsdk/apis/v2/server/pxe.py on lines 34..40

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

                                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

                                            if match:
                                                return True, error_msg
                                            else:
                                                error_msg = (str(self.name) + " should adhere to regex " +
                                                             str(pattern))
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 1 other location - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 379..383

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

                                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

                                            if match:
                                                return True, error_msg
                                            else:
                                                error_msg = (str(self.name) + " should adhere to regex " +
                                                             str(pattern))
                                Severity: Major
                                Found in imcsdk/imccoremeta.py and 1 other location - About 1 hr to fix
                                imcsdk/imccoremeta.py on lines 371..375

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

                                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

                                            if not str(input_value).isdigit():
                                                error_msg = ("Value " + str(input_value) +
                                                             " does not fit the range " +
                                                             str(self.__restriction.range_val))
                                Severity: Minor
                                Found in imcsdk/imccoremeta.py and 1 other location - About 45 mins to fix
                                imcsdk/imccoremeta.py on lines 359..364

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

                                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

                                            if fits_in_range:
                                                return True, error_msg
                                            else:
                                                error_msg = ("Value " + str(value) +
                                                             " does not fit the range" +
                                Severity: Minor
                                Found in imcsdk/imccoremeta.py and 1 other location - About 45 mins to fix
                                imcsdk/imccoremeta.py on lines 395..398

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

                                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