knipknap/exscript

View on GitHub

Showing 245 of 245 total issues

Host has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class Host(object):

    """
    Represents a device on which to open a connection.
    """
Severity: Minor
Found in Exscript/host.py - About 2 hrs to fix

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

    @secure_function
    def pfxmask(scope, ips, pfxlen):
        """
        Applies the given prefix length to the given ips, resulting in a
        (list of) IP network addresses.
    Severity: Major
    Found in Exscript/stdlib/ipv4.py and 1 other location - About 2 hrs to fix
    Exscript/stdlib/ipv4.py on lines 57..71

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

    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

    @secure_function
    def mask(scope, ips, mask):
        """
        Applies the given IP mask (e.g. 255.255.255.0) to the given IP address
        (or list of IP addresses) and returns it.
    Severity: Major
    Found in Exscript/stdlib/ipv4.py and 1 other location - About 2 hrs to fix
    Exscript/stdlib/ipv4.py on lines 126..140

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

    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 __str__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __str__(self):
            """
            Like :class:`to_string()`.
    
            :rtype:  str
    Severity: Minor
    Found in Exscript/util/url.py - About 2 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 clean_ip has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def clean_ip(ip):
        """
        Cleans the ip address up, useful for removing leading zeros, e.g.::
    
            1234:0:01:02:: -> 1234:0:1:2::
    Severity: Minor
    Found in Exscript/util/ipv6.py - About 2 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 get_terminal_size has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_terminal_size(default_rows=25, default_cols=80):
        """
        Returns the number of lines and columns of the current terminal.
        It attempts several strategies to determine the size and if all fail,
        it returns (80, 25).
    Severity: Minor
    Found in Exscript/util/tty.py - About 2 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

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

    def parse_prefix(prefix, default_length=24):
        """
        Splits the given IP prefix into a network address and a prefix length.
        If the prefix does not have a length (i.e., it is a simple IP address),
        it is presumed to have the given default length.
    Severity: Major
    Found in Exscript/util/ipv4.py and 1 other location - About 2 hrs to fix
    Exscript/util/ipv6.py on lines 136..154

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

    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 parse_prefix(prefix, default_length=128):
        """
        Splits the given IP prefix into a network address and a prefix length.
        If the prefix does not have a length (i.e., it is a simple IP address),
        it is presumed to have the given default length.
    Severity: Major
    Found in Exscript/util/ipv6.py and 1 other location - About 2 hrs to fix
    Exscript/util/ipv4.py on lines 166..184

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

    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

    Lexer has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Lexer(object):
    
        def __init__(self, parser_cls, *args, **kwargs):
            """
            The given args are passed to the parser_cls constructor.
    Severity: Minor
    Found in Exscript/parselib/lexer.py - About 2 hrs to fix

      Mail has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Mail(object):
      
          """
          Represents an email.
          """
      Severity: Minor
      Found in Exscript/util/mail.py - About 2 hrs to fix

        Function _decorate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def _decorate(flush=True, attempts=1, only_authenticate=False):
            """
            Wraps the given function such that conn.login() or conn.authenticate() is
            executed.
            Doing the real work for autologin and autoauthenticate to minimize code
        Severity: Minor
        Found in Exscript/util/decorator.py - About 2 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 normalize_ip has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def normalize_ip(ip):
            """
            Transform the address into a standard, fixed-length form, such as:
        
                1234:0:01:02:: -> 1234:0000:0001:0002:0000:0000:0000:0000
        Severity: Minor
        Found in Exscript/util/ipv6.py - About 2 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 get_hosts_from_csv has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_hosts_from_csv(filename,
                               default_protocol='telnet',
                               default_domain='',
                               encoding='utf-8'):
            """
        Severity: Minor
        Found in Exscript/util/file.py - About 2 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

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

        _error_re = [re.compile(r'%Error'),
                     re.compile(r'Invalid input', re.I),
                     re.compile(r'(?:incomplete|ambiguous) command', re.I),
                     re.compile(r'connection timed out', re.I),
                     re.compile(r'[^\r\n]+ not found', re.I)]
        Severity: Major
        Found in Exscript/protocols/drivers/brocade.py and 5 other locations - About 2 hrs to fix
        Exscript/protocols/drivers/ace.py on lines 33..37
        Exscript/protocols/drivers/aruba.py on lines 33..37
        Exscript/protocols/drivers/cienasaos.py on lines 10..14
        Exscript/protocols/drivers/ios.py on lines 36..40
        Exscript/protocols/drivers/nxos.py on lines 32..36

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

        _error_re = [re.compile(r'%Error'),
                     re.compile(r'invalid input', re.I),
                     re.compile(r'(?:incomplete|ambiguous) command', re.I),
                     re.compile(r'connection timed out', re.I),
                     re.compile(r'[^\r\n]+ not found', re.I)]
        Severity: Major
        Found in Exscript/protocols/drivers/ios.py and 5 other locations - About 2 hrs to fix
        Exscript/protocols/drivers/ace.py on lines 33..37
        Exscript/protocols/drivers/aruba.py on lines 33..37
        Exscript/protocols/drivers/brocade.py on lines 35..39
        Exscript/protocols/drivers/cienasaos.py on lines 10..14
        Exscript/protocols/drivers/nxos.py on lines 32..36

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

        _error_re = [re.compile(r'%Error'),
                     re.compile(r'invalid input', re.I),
                     re.compile(r'(?:incomplete|ambiguous) command', re.I),
                     re.compile(r'connection timed out', re.I),
                     re.compile(r'[^\r\n]+ not found', re.I)]
        Severity: Major
        Found in Exscript/protocols/drivers/ace.py and 5 other locations - About 2 hrs to fix
        Exscript/protocols/drivers/aruba.py on lines 33..37
        Exscript/protocols/drivers/brocade.py on lines 35..39
        Exscript/protocols/drivers/cienasaos.py on lines 10..14
        Exscript/protocols/drivers/ios.py on lines 36..40
        Exscript/protocols/drivers/nxos.py on lines 32..36

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

        _error_re = [re.compile(r'SHELL PARSER FAILURE'),
                     re.compile(r'invalid input', re.I),
                     re.compile(r'(?:incomplete|ambiguous) command', re.I),
                     re.compile(r'connection timed out', re.I),
                     re.compile(r'[^\r\n]+ not found', re.I)]
        Severity: Major
        Found in Exscript/protocols/drivers/cienasaos.py and 5 other locations - About 2 hrs to fix
        Exscript/protocols/drivers/ace.py on lines 33..37
        Exscript/protocols/drivers/aruba.py on lines 33..37
        Exscript/protocols/drivers/brocade.py on lines 35..39
        Exscript/protocols/drivers/ios.py on lines 36..40
        Exscript/protocols/drivers/nxos.py on lines 32..36

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

        _error_re = [re.compile(r'%Error'),
                     re.compile(r'invalid input', re.I),
                     re.compile(r'(?:incomplete|ambiguous) command', re.I),
                     re.compile(r'connection timed out', re.I),
                     re.compile(r'[^\r\n]+ not found', re.I)]
        Severity: Major
        Found in Exscript/protocols/drivers/aruba.py and 5 other locations - About 2 hrs to fix
        Exscript/protocols/drivers/ace.py on lines 33..37
        Exscript/protocols/drivers/brocade.py on lines 35..39
        Exscript/protocols/drivers/cienasaos.py on lines 10..14
        Exscript/protocols/drivers/ios.py on lines 36..40
        Exscript/protocols/drivers/nxos.py on lines 32..36

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

        _error_re = [re.compile(r'%Error'),
                     re.compile(r'invalid input', re.I),
                     re.compile(r'(?:incomplete|ambiguous) command', re.I),
                     re.compile(r'connection timed out', re.I),
                     re.compile(r'[^\r\n]+ not found', re.I)]
        Severity: Major
        Found in Exscript/protocols/drivers/nxos.py and 5 other locations - About 2 hrs to fix
        Exscript/protocols/drivers/ace.py on lines 33..37
        Exscript/protocols/drivers/aruba.py on lines 33..37
        Exscript/protocols/drivers/brocade.py on lines 35..39
        Exscript/protocols/drivers/cienasaos.py on lines 10..14
        Exscript/protocols/drivers/ios.py on lines 36..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 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

        File workqueue.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #
        # Copyright (C) 2010-2017 Samuel Abels
        # The MIT License (MIT)
        #
        # Permission is hereby granted, free of charge, to any person obtaining
        Severity: Minor
        Found in Exscript/workqueue/workqueue.py - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language