locomotivecms/steam

View on GitHub
lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method get_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

            def get_attributes(filepath, fullpath)
              if File.directory?(filepath)
                {
                  title:          File.basename(filepath).humanize,
                  listed:         false,
Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb - 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

Method complete_attributes_from_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

            def complete_attributes_from_data(attributes, data, locale)
              return if attributes.nil? # shouldn't happen (undeleted page? local files out of date?)

              # this is super important to handle correctly url type settings in sections
              attributes[:_id] = data['id']
Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb - 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

Method load_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

            def load_data
              Dir.glob(File.join(data_path, '**', '*.json')).each do |filepath|
                filepath  =~ /#{data_path}\/([a-z]+)\//
                data      = safe_json_file_load(filepath)
                locale    = $1.to_sym
Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb - 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

Method each_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

            def each_file(&block)
              Dir.glob(File.join(path, '**', '*')).each do |filepath|
                next unless is_liquid_file?(filepath)

                relative_path = get_relative_path(filepath)
Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb - 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

Method load_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def load_tree
              # load the core pages and layouts from the app/views/pages folder
              each_file do |filepath, fullpath, locale|
                if leaf = @pages_by_fullpath[fullpath]
                  update(leaf, filepath, fullpath, locale)
Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb - 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

There are no issues that match your filters.

Category
Status