Showing 61 of 61 total issues
File snapshotting.py
has 546 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import (absolute_import, print_function)
# From system
import os
import re
Function upload_file
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def upload_file(bucket, source, destination, s3_ssenc, bufsize, reduced_redundancy, rate_limit, quiet):
mp = None
retry_count = 0
sleep_time = SLEEP_TIME
while True:
- Read upRead up
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 create_upload_manifest
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def create_upload_manifest(
snapshot_name, snapshot_keyspaces, snapshot_table,
conf_path, manifest_path, exclude_tables, incremental_backups=False):
if snapshot_keyspaces:
keyspace_globs = snapshot_keyspaces.split(',')
- Read upRead up
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
File main.py
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import (absolute_import, print_function)
# From system
from collections import defaultdict
from fabric.api import env
Function __init__
has 22 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, aws_secret_access_key,
File agent.py
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import (absolute_import, print_function)
import boto
from boto.s3.connection import S3Connection
from yaml import load
Function node_start_backup
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def node_start_backup(self, snapshot, incremental_backups):
"""Runs snapshot command on a cassandra node"""
def run_cmd(cmd):
with hide('running', 'stdout', 'stderr'):
- Read upRead up
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 main
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main():
base_parser = add_s3_arguments(_base_parser)
subparsers = base_parser.add_subparsers(
title='subcommands', dest='subcommand'
)
Function upload_node_backups
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def upload_node_backups(self, snapshot, incremental_backups):
prefix = os.path.join(snapshot.base_path,
self.get_current_node_hostname())
manifest_path = '/tmp/backupmanifest'
- Read upRead up
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 put_from_manifest
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def put_from_manifest(
Function configure
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def configure(*args, **kwargs):
"""
Configure logging.
Borrowed from logging.basicConfig
Uses the IndentFormatter instead of the regular Formatter
- Read upRead up
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 restore
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def restore(self, keyspace, table, hosts, target_hosts):
table_log = "table: %s" % table if table else ''
snap_name = os.path.basename(self.snapshot.base_path)
logging.info("Restoring keyspace: %(keyspace)s %(table)s "
"from backup %(snap)s" %
- Read upRead up
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 restore_backup
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def restore_backup(args):
snapshots = SnapshotCollection(
args.aws_access_key_id,
args.aws_secret_access_key,
args.s3_base_path,
- Read upRead up
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 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, aws_access_key_id, aws_secret_access_key, snapshot,
Function upload_file
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def upload_file(bucket, source, destination, s3_ssenc, bufsize, reduced_redundancy, rate_limit, quiet):
Function compressed_pipe
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def compressed_pipe(path, size, rate_limit, quiet):
"""
Returns a generator that yields compressed chunks of
the given file_path
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function run_backup
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def run_backup(args):
if args.user:
env.user = args.user
if args.password:
- Read upRead up
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 create_upload_manifest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_upload_manifest(
Similar blocks of code found in 2 locations. Consider refactoring. Open
def start_cluster_backup(self, snapshot, incremental_backups=False):
logging.info("Creating snapshots")
with settings(parallel=True, pool_size=self.connection_pool_size):
execute(self.node_start_backup, snapshot, incremental_backups)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 36.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def upload_cluster_backups(self, snapshot, incremental_backups):
logging.info("Uploading backups")
with settings(parallel=True, pool_size=self.connection_pool_size):
execute(self.upload_node_backups, snapshot, incremental_backups)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 36.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76