autotelik/datashift

View on GitHub
lib/datashift/mapping/data_flow_schema.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method prepare_from_yaml has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')

      @yaml_data = yaml

      raise "Bad YAML syntax  - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]
Severity: Minor
Found in lib/datashift/mapping/data_flow_schema.rb - About 3 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

Assignment Branch Condition size for prepare_from_yaml is too high. [63/60]
Open

    def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')

      @yaml_data = yaml

      raise "Bad YAML syntax  - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method prepare_from_yaml has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')

      @yaml_data = yaml

      raise "Bad YAML syntax  - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]
Severity: Minor
Found in lib/datashift/mapping/data_flow_schema.rb - About 2 hrs to fix

    TODO found
    Open

            # TODO: - do we really need to pass in the doc context when parent nodes already has it ?

    TODO found
    Open

          # TODO: fix doc context so it can be created 'empty' i.e without AR klass, and always has empty headers

    TODO found
    Open

              # TODO: what is c ?   a list or hash ?

    TODO found
    Open

                  # TODO: - This index could be hard coded by the user in YAML or we try to derive it from the headers

    TODO found
    Open

              # TODO: - layout with heading is verbose for no benefit - defunct, simply node.source, node.presentation

    TODO found
    Open

                  # TODO: validate type ? guess we expect one of ModelMethod.supported_types_enum

    Unnecessary spacing detected.
    Open

            binding = MethodBinding.new(mm.operator, mm, idx: i)  # TOFIX - why need to pass in both mm.operator AND mm ??

    This cop checks for extra/unnecessary whitespace.

    Example:

    # good if AllowForAlignment is true
    name      = "RuboCop"
    # Some comment and an empty line
    
    website  += "/bbatsov/rubocop" unless cond
    puts        "rubocop"          if     debug
    
    # bad for any configuration
    set_app("RuboCop")
    website  = "https://github.com/bbatsov/rubocop"

    There are no issues that match your filters.

    Category
    Status