andry81/tacklelib

View on GitHub

Showing 58 of 64 total issues

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

            if not var_value is None:
              var_value = var_value.replace('\\', '/')
              if var_value is None:
                if not search_in_expand_dict_at_second is None:
                  var_value = search_in_expand_dict_at_second.get(var_name)
Severity: Major
Found in python/tacklelib/tacklelib.yaml.py and 1 other location - About 7 hrs to fix
python/tacklelib/tacklelib.yaml.py on lines 171..180

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

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

            if not var_value is None:
              var_value = var_value.replace('\\', '/')
              if var_value is None:
                if not search_in_expand_dict_at_second is None:
                  var_value = search_in_expand_dict_at_second.get(var_name)
Severity: Major
Found in python/tacklelib/tacklelib.yaml.py and 1 other location - About 7 hrs to fix
python/tacklelib/tacklelib.yaml.py on lines 146..155

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

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

def parse_dir(dir_path, sort_by = 'line'):
  for dirpath, dirs, files in os.walk(dir_path):
    for dir in dirs:
      # ignore directories beginning by '.'
      if str(dir)[0:1] == '.':
Severity: Minor
Found in python/tacklelib/tools/list_urls_in_files.py - About 5 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 expand_list has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def expand_list(self, list_value, search_in_expand_dict_at_second = None, search_by_pred_at_third = None, list_as_cmdline = False):
    if not isinstance(list_value, list):
      raise Exception('list_value is not a list type' + str(type(list_value)))

    is_list_to_string_convertible = True
Severity: Minor
Found in python/tacklelib/tacklelib.yaml.py - About 5 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 3 locations. Consider refactoring.
Open

python_tests/unit/01_import_module/01_basic_import/inc2/testlib.inc2.py on lines 0..10
python_tests/unit/01_import_module/02_mixed_import/testlib.test.py on lines 0..10

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

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

python_tests/unit/01_import_module/01_basic_import/inc2/testlib.inc2.py on lines 0..10
python_tests/unit/01_import_module/01_basic_import/inc3/testlib.inc3.py on lines 0..10

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

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

python_tests/unit/01_import_module/01_basic_import/inc3/testlib.inc3.py on lines 0..10
python_tests/unit/01_import_module/02_mixed_import/testlib.test.py on lines 0..10

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

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

          try:
            return FileCache_.__setitem__(self, key, value)
          except (OSError, EOFError) as e:
            # OSError: [WinError 6800] The function attempted to use a name that is reserved for use by another transaction: ...
            # EOFError: Ran out of input (pickle.loads(...))
Severity: Major
Found in python/tacklelib/tacklelib.cache.py and 1 other location - About 4 hrs to fix
python/tacklelib/tacklelib.cache.py on lines 63..75

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

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

  def expand_dict(self, dict_value, search_in_expand_dict_at_second = None, search_by_pred_at_third = None, ignore_types = None, list_as_cmdline = False):
    if not isinstance(dict_value, dict):
      raise Exception('dict_value is not a dictionary type' + str(type(dict_value)))

    out_value = {}
Severity: Minor
Found in python/tacklelib/tacklelib.yaml.py - About 4 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

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

          try:
            return FileCache_.__getitem__(self, key)
          except (OSError, EOFError) as e:
            # OSError: [WinError 6800] The function attempted to use a name that is reserved for use by another transaction: ...
            # EOFError: Ran out of input (pickle.loads(...))
Severity: Major
Found in python/tacklelib/tacklelib.cache.py and 1 other location - About 4 hrs to fix
python/tacklelib/tacklelib.cache.py on lines 90..102

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

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

    if not remove_pred is None:
      if not isinstance(remove_pred, types.LambdaType):
        raise Exception('remove_pred is not a lambda type' + str(type(remove_pred)))
      for key in last_stack_record[1]:
        remove_pred(key)
Severity: Major
Found in python/tacklelib/tacklelib.yaml.py and 1 other location - About 3 hrs to fix
python/tacklelib/tacklelib.yaml.py on lines 41..45

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

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

    if not remove_pred is None:
      if not isinstance(remove_pred, types.LambdaType):
        raise Exception('remove_pred is not a lambda type' + str(type(remove_pred)))
      for key in last_stack_record[1]:
        remove_pred(key)
Severity: Major
Found in python/tacklelib/tacklelib.yaml.py and 1 other location - About 3 hrs to fix
python/tacklelib/tacklelib.yaml.py on lines 59..63

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

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 tacklelib.yaml.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# pure python module for commands w/o extension modules usage

import os, re, types, copy

class YamlConfig(dict):
Severity: Minor
Found in python/tacklelib/tacklelib.yaml.py - About 2 hrs to fix

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

      def sync(self):
        if platform.system() == 'Windows':
          prev_stderr = sys.stderr
          devnull = tkl.devnull()
          with tkl.OnExit(lambda: [None for sys.stderr in [prev_stderr]]):
    Severity: Minor
    Found in python/tacklelib/tacklelib.cache.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 tkl_membercopy has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def tkl_membercopy(x, from_globals, to_globals):
      #print('membercopy:', x)
      if id(from_globals) != id(to_globals):
        if inspect.isfunction(x):
          return type(x)(x.__code__, to_globals, x.__name__, x.__defaults__, x.__closure__)
    Severity: Minor
    Found in python/tacklelib/tacklelib.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

    TmpFileIO has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TmpFileIO:
      def __init__(self, mode = 'r', buffering = -1, encoding = None, errors = None, newline = None, closefd = True, opener = None):
        self.fd, self.path = tempfile.mkstemp()
        self.file = None
        try:
    Severity: Minor
    Found in python/tacklelib/tacklelib.io.py - About 2 hrs to fix

      Function __setitem__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def __setitem__(self, key, value):
          if platform.system() == 'Windows':
            prev_stderr = sys.stderr
            devnull = tkl.devnull()
            with tkl.OnExit(lambda: [None for sys.stderr in [prev_stderr]]):
      Severity: Minor
      Found in python/tacklelib/tacklelib.cache.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 __getitem__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def __getitem__(self, key):
          if platform.system() == 'Windows':
            prev_stderr = sys.stderr
            devnull = tkl.devnull()
            with tkl.OnExit(lambda: [None for sys.stderr in [prev_stderr]]):
      Severity: Minor
      Found in python/tacklelib/tacklelib.cache.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 tkl_get_stack_frame_module_by_name has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def tkl_get_stack_frame_module_by_name(name = '<module>'):
        target_module = None
      
        # search for the first module in the stack
        stack_frame = inspect.currentframe()
      Severity: Minor
      Found in python/tacklelib/tacklelib.py - About 1 hr 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 print_max has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def print_max(str, max_lines = 9):
        if max_lines >= 0:
          num_new_lines = str.count('\n')
          if num_new_lines > max_lines:
            line_index = 0
      Severity: Minor
      Found in python/tacklelib/tacklelib.utils.py - About 1 hr 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

      Severity
      Category
      Status
      Source
      Language