blendernc/blendernc

View on GitHub

Showing 35 of 35 total issues

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

        if socket.unique_identifier in socket.dataset.keys():
            dataset = socket.dataset[node.blendernc_dataset_identifier].copy()
            node.blendernc_dict[node.blendernc_dataset_identifier] = dataset
Severity: Major
Found in blendernc/decorators.py and 1 other location - About 2 hrs to fix
blendernc/decorators.py on lines 177..184

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

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 (
                node_parent.blendernc_dataset_identifier
                in node_parent.blendernc_dict.keys()
            ):
                dataset = node_parent.blendernc_dict[
Severity: Major
Found in blendernc/decorators.py and 1 other location - About 2 hrs to fix
blendernc/decorators.py on lines 166..168

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

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

    def execute(self, context):
        NodeTrees = get_blendernc_nodetrees()
        cache = bpy.context.scene.datacube_cache
        if cache.keys():
            for NodeTree in NodeTrees:
Severity: Minor
Found in blendernc/UI_operators.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 is_connected has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def is_connected(cls, func):
        """ """

        @functools.wraps(func)
        def wrapper_update(node, context, layout):
Severity: Minor
Found in blendernc/decorators.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 update_image has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def update_image(self):
        self.timer.tick("Variable load")
        # Get the data of the selected variable and grid
        var_data = bnc_gutils.get_var_data(self.node)
        self.timer.tick("Variable load")
Severity: Minor
Found in blendernc/core/update_ui.py - About 1 hr to fix

    Function load_handler has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_handler(dummy):
        pref = preferences.get_addon_preference()
        if pref.blendernc_autoreload_datasets:
            blendernc_nodetrees = bnc_gutils.get_blendernc_nodetrees()
            for blendernc_nodetree in blendernc_nodetrees:
    Severity: Minor
    Found in blendernc/handlers.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 get_new_identifier has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_new_identifier(node):
        nodetrees = get_blendernc_nodetrees()
        counter = 0
        identif_list = [0]
        for nodetree in nodetrees:
    Severity: Minor
    Found in blendernc/get_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

    Function plot_using_grid has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def plot_using_grid(x, y, data, vmin, vmax, dpi=300, xlim=None, ylim=[-90, 90]):
    Severity: Major
    Found in blendernc/python_functions.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if len(link_keys) == 1 and operation not in operation_types["unique"]:
                  self.inputs.new("bNCfloatSocket", "Float")
              elif len(link_keys) > 1 and operation in operation_types["unique"]:
                  self.inputs.remove(self.inputs[-1])
              elif (
      Severity: Major
      Found in blendernc/nodes/math/BlenderNC_NT_math.py - About 1 hr to fix

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

            def amIconnected(node):
                # Connections dictionary
                connections = {"input": [], "output": []}
                # Test input
                inputs = [ii for ii in node.inputs] if node.inputs else node.inputs
        Severity: Minor
        Found in blendernc/decorators.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 create_sockets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_sockets(self, operation):
                link_keys = self.inputs.keys()
                if len(link_keys) == 1 and operation not in operation_types["unique"]:
                    self.inputs.new("bNCfloatSocket", "Float")
                elif len(link_keys) > 1 and operation in operation_types["unique"]:
        Severity: Minor
        Found in blendernc/nodes/math/BlenderNC_NT_math.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, context, node, node_tree, frame, image, grid_node=None):
        Severity: Minor
        Found in blendernc/core/update_ui.py - About 45 mins to fix

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

          def name_match(block, cfname, filename):
              if not cfname and (block.a != 0 or block.b != 0):
                  raise ValueError("Start of filename strings do not match.")
              elif block.a == block.b and block.size != 0:
                  if len(cfname) != 0 and len(cfname) != block.a:
          Severity: Minor
          Found in blendernc/UI_operators.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 update_colorramp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def update_colorramp(self, context):
              if not self.colormaps:
                  return
              else:
                  cmap_steps = self.n_stops
          Severity: Minor
          Found in blendernc/nodes/cmaps/cmapsnode.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 update_datetime_text has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def update_datetime_text(
              node,
              node_tree,
              frame,
              time_text="",
          Severity: Minor
          Found in blendernc/core/update_ui.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 force_init_load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def force_init_load(cls, node):
                  node_walked = [node]
                  identifier = node.blendernc_dataset_identifier
          
                  # Trick to reload data when starting blender
          Severity: Minor
          Found in blendernc/decorators.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def execute(self, context):
                  act_obj = (
                      context.active_object
                      if context.active_object.select_get() is True
                      else None
          Severity: Minor
          Found in blendernc/operators.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

              if importlib.find_loader("xarray"):
                  print("Registering to Change Defaults")
                  bpy.app.handlers.load_factory_startup_post.append(import_workspace)
                  bpy.app.handlers.load_factory_startup_post.append(load_handler_for_startup)
          Severity: Minor
          Found in blendernc/__init__.py and 1 other location - About 40 mins to fix
          blendernc/__init__.py on lines 69..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 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

              if (
                  importlib.find_loader("xarray")
                  and load_handler_for_startup in bpy.app.handlers.load_factory_startup_post
              ):
                  print("Unregistering to Change Defaults")
          Severity: Minor
          Found in blendernc/__init__.py and 1 other location - About 40 mins to fix
          blendernc/__init__.py on lines 47..50

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

          def normalize_data_w_grid(node, data, grid_node, vmax, vmin):
          Severity: Minor
          Found in blendernc/python_functions.py - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language