gamunu/cassandra_snap

View on GitHub

Showing 61 of 61 total issues

Avoid deeply nested control flow statements.
Open

                    if f.split('/')[-4] not in exclude_tables_list:
                        files.append(f.strip())
            else:
Severity: Major
Found in cassandra_snap/agent.py - About 45 mins to fix

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

        def _download_key(self, key):
            r = self.keyspace_table_matcher.search(key.name)
            keyspace = r.group(2)
            table = r.group(3)
            host = key.name.split('/')[2]
    Severity: Minor
    Found in cassandra_snap/snapshotting.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 cancel_upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def cancel_upload(bucket, mp, remote_path):
        """
        Safe way to cancel a multipart upload
        sleeps SLEEP_TIME seconds and then makes sure that there are not parts left
        in storage
    Severity: Minor
    Found in cassandra_snap/agent.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

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

                try:
                    for i, chunk in enumerate(compressed_pipe(source, bufsize, rate_limit, quiet)):
                        mp.upload_part_from_file(
                            chunk, i + 1, cb=s3_progress_update_callback)
                except Exception as exc:
    Severity: Minor
    Found in cassandra_snap/agent.py and 1 other location - About 40 mins to fix
    cassandra_snap/agent.py on lines 72..81

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

    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

                    try:
                        mp = bucket.initiate_multipart_upload(
                            destination, encrypt_key=s3_ssenc, reduced_redundancy=reduced_redundancy)
                        logger.info("Initialized multipart upload for file {!s} to {!s}".format(
                            source, destination))
    Severity: Minor
    Found in cassandra_snap/agent.py and 1 other location - About 40 mins to fix
    cassandra_snap/agent.py on lines 83..91

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

    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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in cassandra_snap/snapshotting.py - About 35 mins to fix

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

          def __init__(self, base_path, s3_bucket, hosts, keyspaces, table):
      Severity: Minor
      Found in cassandra_snap/snapshotting.py - About 35 mins to fix

        Function _read_s3 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _read_s3(self):
                if self.snapshots:
                    return
        
                conn = S3Connection(
        Severity: Minor
        Found in cassandra_snap/snapshotting.py - About 35 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 get_snapshot_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_snapshot_for(self, hosts, keyspaces, table):
                """Returns the most recent compatible snapshot"""
                for snapshot in self:
                    if snapshot.hosts != hosts:
                        continue
        Severity: Minor
        Found in cassandra_snap/snapshotting.py - About 35 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 get_keyspace_schema has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_keyspace_schema(self, keyspace=None):
                if self.cqlsh_user and self.cqlsh_password:
                    auth = "-u {!s} -p {!s}".format(self.cqlsh_user,
                                                    self.cqlsh_password)
                else:
        Severity: Minor
        Found in cassandra_snap/snapshotting.py - About 25 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

        Line too long (80 > 79 characters)
        Open

                # Remove the root dir from the list since it won't have a manifest file.
        Severity: Minor
        Found in cassandra_snap/snapshotting.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (132 > 79 characters)
        Open

                               ((bucket, f, destination_path(s3_base_path, f), s3_ssenc, buffer_size, reduced_redundancy, rate_limit, quiet)
        Severity: Minor
        Found in cassandra_snap/agent.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (84 > 79 characters)
        Open

                help="The file containing the private ssh key to use to connect with hosts")
        Severity: Minor
        Found in cassandra_snap/main.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Invalid escape sequence '.'
        Open

                            '\.lzo$', '', key_full_path)
        Severity: Minor
        Found in cassandra_snap/snapshotting.py by pep8

        Invalid escape sequences are deprecated in Python 3.6.

        Okay: regex = r'\.png$'
        W605: regex = '\.png$'

        Line too long (81 > 79 characters)
        Open

                upload_command = "cassandra-snapshotter-agent %(incremental_backups)s " \
        Severity: Minor
        Found in cassandra_snap/snapshotting.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (93 > 79 characters)
        Open

                    self.aws_access_key_id, self.aws_secret_access_key, host=self.s3_connection_host)
        Severity: Minor
        Found in cassandra_snap/snapshotting.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (80 > 79 characters)
        Open

                                 CassandraSnapshotterLogger._fmt_structured(structured))
        Severity: Minor
        Found in cassandra_snap/logging_helper.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (87 > 79 characters)
        Open

                                "lzop Out: %s\nError:%s\nExit Code %d: " % (out, err, errcode))
        Severity: Minor
        Found in cassandra_snap/snapshotting.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (80 > 79 characters)
        Open

                        # The multi-part object may be in a bad state.  Extract an error
        Severity: Minor
        Found in cassandra_snap/agent.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (80 > 79 characters)
        Open

                logging.info("Found %(files_count)d files, with total size of %(size)s."
        Severity: Minor
        Found in cassandra_snap/snapshotting.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.
        Severity
        Category
        Status
        Source
        Language