boroivanov/ecs-tools

View on GitHub
ecstools/resources/service.py

Summary

Maintainability
A
2 hrs
Test Coverage

Service has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Service(object):
    def __init__(self, ecs, ecr, cluster, service):
        self.ecs = ecs
        self.ecr = ecr
        self._cluster = cluster
Severity: Minor
Found in ecstools/resources/service.py - About 2 hrs to fix

    Either remove or fill this block of code.
    Open

                pass
    Severity: Major
    Found in ecstools/resources/service.py by sonar-python

    Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

    Noncompliant Code Example

    for i in range(3):
        pass
    

    Exceptions

    When a block contains a comment, this block is not considered to be empty.

    Either merge this branch with the identical one on line "171" or change one of the implementations.
    Open

                    click.echo(e, err=True)
    Severity: Major
    Found in ecstools/resources/service.py by sonar-python

    Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

    Noncompliant Code Example

    if 0 <= a < 10:
        do_the_thing()
    elif 10 <= a < 20:
        do_the_other_thing()
    elif 20 <= a < 50:
        do_the_thing()  # Noncompliant; duplicates first condition
    else:
        do_the_rest()
    
    b = 4 if a > 12 else 4
    

    Compliant Solution

    if (0 <= a < 10) or (20 <= a < 50):
        do_the_thing()
    elif 10 <= a < 20:
        do_the_other_thing()
    else:
        do_the_rest()
    
    b = 4
    

    or

    if 0 <= a < 10:
        do_the_thing()
    elif 10 <= a < 20:
        do_the_other_thing()
    elif 20 <= a < 50:
        do_the_third_thing()
    else:
        do_the_rest()
    
    b = 8 if a > 12 else 4
    

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

            except ClientError as e:
                if e.response['Error']['Code'] == 'ClusterNotFoundException':
                    click.echo('Cluster not found.', err=True)
                else:
                    click.echo(e, err=True)
    Severity: Major
    Found in ecstools/resources/service.py and 1 other location - About 3 hrs to fix
    ecstools/commands/service/ls.py on lines 33..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 66.

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

            try:
                self.ecs.update_service(**params)
            except ClientError as e:
                click.echo(e.response['Error']['Message'], err=True)
                sys.exit(1)
    Severity: Major
    Found in ecstools/resources/service.py and 1 other location - About 1 hr to fix
    ecstools/resources/task_definition.py on lines 14..19

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

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

            if verbose:
                click.secho('Deploying %s to %s %s...' % (
                    taskDefinition.revision(),
                    self.cluster(),
                    self.name()),
    Severity: Minor
    Found in ecstools/resources/service.py and 1 other location - About 45 mins to fix
    ecstools/commands/task-definition/ls.py on lines 65..67

    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