locomotivecms/wagon

View on GitHub

Showing 42 of 42 total issues

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

class Manager {

  constructor() {
    this.sections = {};
  }
Severity: Major
Found in generators/webpack/app/assets/javascripts/sections/_manager.js and 1 other location - About 4 days to fix
generators/blank/app/assets/javascripts/sections/_manager.js on lines 1..93

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

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

class Manager {

  constructor() {
    this.sections = {};
  }
Severity: Major
Found in generators/blank/app/assets/javascripts/sections/_manager.js and 1 other location - About 4 days to fix
generators/webpack/app/assets/javascripts/sections/_manager.js on lines 1..93

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

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

module.exports = {
  entry: './app/assets/javascripts/app.js',
  output: {
    path:     path.resolve(__dirname, '../../public'),
    filename: 'javascripts/bundle.js'
Severity: Major
Found in generators/webpack/app/assets/webpack.common.js and 1 other location - About 1 day to fix
generators/blank/app/assets/webpack.common.js on lines 5..57

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

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

module.exports = {
  entry: './app/assets/javascripts/app.js',
  output: {
    path:     path.resolve(__dirname, '../../public'),
    filename: 'javascripts/bundle.js'
Severity: Major
Found in generators/blank/app/assets/webpack.common.js and 1 other location - About 1 day to fix
generators/webpack/app/assets/webpack.common.js on lines 5..57

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

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 cli.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'thor'
require 'thor/runner'

module Locomotive
  module Wagon
Severity: Minor
Found in lib/locomotive/wagon/cli.rb - About 4 hrs to fix

    Method template has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def template
            %{
    <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    Severity: Major
    Found in lib/locomotive/wagon/middlewares/error_page.rb - About 3 hrs to fix

      Method parse has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse(chars)
              curlies, escaping = 0, false
              chars.map do |char|
                if escaping
                  escaping = false
      Severity: Minor
      Found in lib/locomotive/wagon/tools/glob.rb - 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

      Method decode_json_attribute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def decode_json_attribute(attributes, name, &block)
            value = attributes.delete(name)
      
            return if value.blank?
      
      

      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 parse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse(chars)
              curlies, escaping = 0, false
              chars.map do |char|
                if escaping
                  escaping = false
      Severity: Minor
      Found in lib/locomotive/wagon/tools/glob.rb - About 1 hr to fix

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

              def smoosh(chars)
                [].tap do |out|
                  until chars.empty?
                    char = chars.shift
                    if char == "*" and chars.first == "*"
        Severity: Minor
        Found in lib/locomotive/wagon/tools/glob.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 write_page has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def write_page(page, locale = nil)
              instrument :writing, label: "#{page.fullpath} (#{locale})"
        
              filepath = data_path(page, locale)
        
        

          Method persist has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def persist(decorated_entity)
                _attributes = decorated_entity.to_hash
          
                # push the picture only if there is no existing remote picture
                _attributes.delete(:picture) if remote_site['picture_url'].present?

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

              def fetch_content_entries(content_type, &block)
                page = 1
                while page do
                  entries, _next_page = {}, nil
          
          

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

                    def to_json
                      self._list.map do |template|
                        # puts template.klass.class_options.inspect
                        # puts class_options_to_json
                        path = template.klass.source_root ? File.expand_path(template.klass.source_root) : nil
          Severity: Minor
          Found in lib/locomotive/wagon/generators/site.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 connection_information has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def connection_information
                if information = read_deploy_settings(self.env, self.path)
                  # the deployment env exists and contains all the information we need to move on
                  information
                else
          Severity: Minor
          Found in lib/locomotive/wagon/commands/push_command.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 prepare_value_for_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def prepare_value_for_hash(value)
                if value.is_a?(Array) && value.any? { |v| v.respond_to?(:__attributes__) }
                  value.map(&:to_hash)
                elsif value.is_a?(Array) && value.empty?
                  nil # reset the array
          Severity: Minor
          Found in lib/locomotive/wagon/decorators/concerns/to_hash_concern.rb - About 55 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 check_path! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def check_path!(path = nil)
                    path ||= options['path']
          
                    path = path == '.' ? Dir.pwd : File.expand_path(path)
          
          
          Severity: Minor
          Found in lib/locomotive/wagon/cli.rb - About 55 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 extract_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def extract_fields(fields)
                    fields.map do |raw_attributes|
                      name, type, label, required, localized, target_content_type_slug  = raw_attributes.split(':')
          
                      OpenStruct.new(
          Severity: Minor
          Found in lib/locomotive/wagon/generators/content_type.rb - About 55 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 replace_asset_urls has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def replace_asset_urls(content)
                return '' if content.blank?
          
                _content = content.dup
          
          

          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

          module.exports = merge(common, {
            plugins: [
              new OptimizeCssAssetsPlugin({
                assetNameRegExp: /\.css$/,
                cssProcessorOptions: { discardComments: { removeAll: true } }
          Severity: Minor
          Found in generators/blank/app/assets/webpack.prod.js and 1 other location - About 50 mins to fix
          generators/webpack/app/assets/webpack.prod.js on lines 5..12

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

          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

          Severity
          Category
          Status
          Source
          Language