private-dreamnet/dreampower

View on GitHub

Showing 100 of 100 total issues

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

    def correct_color(img, percent):
        """
        Correct the color of an image.

        :param img: <RGB> Image to correct
Severity: Minor
Found in src/transform/opencv/correct.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 run_worker has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def run_worker(klass, image_step, config=None):
    r = None
    for k in ("gan", "opencv"):
        if workers.get(k).get(klass) is not None:
            #Conf.log.debug("wk {}".format(workers.get(k).get(klass)))
Severity: Minor
Found in src/processing/worker.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

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

    Conf.log.success("Done! We have taken {} seconds".format(round(time.time() - start, 2)))
Severity: Minor
Found in src/main.py and 1 other location - About 30 mins to fix
src/transform/gan/__init__.py on lines 41..41

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

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

        Conf.log.debug("Model load done in {} seconds".format(round(time.time() - start, 2)))
Severity: Minor
Found in src/transform/gan/__init__.py and 1 other location - About 30 mins to fix
src/main.py on lines 27..27

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

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

def find_min(bp_list, min_a, min_b, min_diff):
    for a, _ in enumerate(bp_list):
        for b, _ in enumerate(bp_list):
            # TODO: avoid repetition (1,0) (0,1)
            diff = abs(bp_list[a].y - bp_list[b].y)
Severity: Minor
Found in src/transform/opencv/bodypart/extract.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

Function is_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def is_file(args, path):
    if not os.path.isfile(path):
        return False

    for mod in (overlay, auto_resize, auto_resize_crop, auto_rescale):
Severity: Minor
Found in src/processing/utils.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

Function __draw_ellipse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def __draw_ellipse(a_max, a_min, angle, aurmax, aurmin, details, hairmax, hairmin, nipmax, nipmin, obj,
                       titmax, titmin, vagmax, vagmin, x, y):
        # Draw ellipse
        if obj.name == "tit":
            cv2.ellipse(details, (x, y), (titmax, titmin), angle, 0, 360, (0, 205, 0), -1)  # (0,0,0,50)
Severity: Minor
Found in src/transform/opencv/mask.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

Function download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def download(_):
    """
    Start checkpoints download logic.

    :param _: None
Severity: Minor
Found in src/checkpoints.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

Function arg_step has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def arg_step(parser):
    def check_steps_args():
        def type_func(a):
            if not re.match(r"^[0-5]:[0-5]$", a):
                raise parser.error("Incorrect skip format. "
Severity: Minor
Found in src/argv/run/argument.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

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Open

        random_tit_factor = random.randint(2, 5)  # TOTEST

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Open

        new_w = tits_list[1].w * random.uniform(0.03, 0.1)  # TOTEST

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Open

            hair_h = vag.h * random.uniform(0.4, 1.5)

Consider possible security implications associated with subprocess module.
Open

import subprocess
Severity: Info
Found in src/scripts/build.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        temp_path = tempfile.mktemp(".jpg")
Severity: Minor
Found in src/transform/opencv/resize.py by bandit

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Open

        nip_dim = int(5 + aur.w * random.uniform(0.03, 0.09))

Rename function "cd" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def cd(newdir):
Severity: Major
Found in src/scripts/_common.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Method "__init__" has 8 parameters, which is greater than the 7 authorized.
Open

            self,
            input_nc,
            output_nc,
            ngf=64,
            n_downsampling=3,
Severity: Major
Found in src/transform/gan/generator.py by sonar-python

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

def do_something(param1, param2, param3, param4, param5):
    ...

Compliant Solution

def do_something(param1, param2, param3, param4):
    ...

Remove this commented out code.
Open

        #if self._gpu_ids:
Severity: Major
Found in src/transform/gan/__init__.py by sonar-python

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

See

  • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
  • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
  • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
  • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

Remove this commented out code.
Open

    #return p
Severity: Major
Found in src/processing/utils.py by sonar-python

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

See

  • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
  • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
  • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
  • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

Rename field "parser"
Open

    parser = None
Severity: Major
Found in src/argv/__init__.py by sonar-python

It's confusing to have a class member with the same name (case differences aside) as its enclosing class. This is particularly so when you consider the common practice of naming a class instance for the class itself.

Best practice dictates that any field or member with the same name as the enclosing class be renamed to be more descriptive of the particular aspect of the class it represents or holds.

Noncompliant Code Example

class Foo:
  foo = ''

  def getFoo(self):
    ...

foo = Foo()
foo.getFoo() # what does this return?

Compliant Solution

class Foo:
  name = ''

  def getName(self):
    ...

foo = Foo()
foo.getName()
Severity
Category
Status
Source
Language