locomotivecms/engine

View on GitHub

Showing 169 of 169 total issues

Function render has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { input, suggestions, loading } = this.state;
    const inputProps = {
      placeholder:  this.props.placeholder,
      value:        input || '',

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

                {value !== null && (
                  <button
                    className="btn btn-default btn-sm"
                    onClick={e => handleChange(null)}
                  >
    Severity: Major
    Found in app/javascript/src/locomotive/editor/inputs/image_picker.js and 3 other locations - About 55 mins to fix
    app/javascript/src/locomotive/editor/inputs/asset_picker.js on lines 47..54
    app/javascript/src/locomotive/editor/inputs/content_entry.js on lines 38..45
    app/javascript/src/locomotive/editor/inputs/url.js on lines 63..70

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

    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

            <button className="btn btn-default btn-sm" onClick={e => openPicker(props)}>
              {i18n.t(url === null ? 'inputs.url.select_button' : 'inputs.url.change_button')}
            </button>
    Severity: Minor
    Found in app/javascript/src/locomotive/editor/inputs/url.js and 1 other location - About 55 mins to fix
    app/javascript/src/locomotive/editor/inputs/content_entry.js on lines 34..36

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

    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

            <button className="btn btn-default btn-sm" onClick={e => openPicker(props)}>
              {i18n.t(entry === null ? 'inputs.content_entry.select_button' : 'inputs.content_entry.change_button')}
            </button>
    Severity: Minor
    Found in app/javascript/src/locomotive/editor/inputs/content_entry.js and 1 other location - About 55 mins to fix
    app/javascript/src/locomotive/editor/inputs/url.js on lines 60..62

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

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

            {url !== null && (
              <button
                className="btn btn-default btn-sm ml-3"
                onClick={e => handleChange(null)}
              >
    Severity: Major
    Found in app/javascript/src/locomotive/editor/inputs/url.js and 3 other locations - About 55 mins to fix
    app/javascript/src/locomotive/editor/inputs/asset_picker.js on lines 47..54
    app/javascript/src/locomotive/editor/inputs/content_entry.js on lines 38..45
    app/javascript/src/locomotive/editor/inputs/image_picker.js on lines 85..92

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

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

                {value !== null && (
                  <button
                    className="btn btn-default btn-sm"
                    onClick={e => handleChange(null)}
                  >
    Severity: Major
    Found in app/javascript/src/locomotive/editor/inputs/asset_picker.js and 3 other locations - About 55 mins to fix
    app/javascript/src/locomotive/editor/inputs/content_entry.js on lines 38..45
    app/javascript/src/locomotive/editor/inputs/image_picker.js on lines 85..92
    app/javascript/src/locomotive/editor/inputs/url.js on lines 63..70

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

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

            {entry !== null && (
              <button
                className="btn btn-default btn-sm"
                onClick={e => handleChange(null)}
              >
    Severity: Major
    Found in app/javascript/src/locomotive/editor/inputs/content_entry.js and 3 other locations - About 55 mins to fix
    app/javascript/src/locomotive/editor/inputs/asset_picker.js on lines 47..54
    app/javascript/src/locomotive/editor/inputs/image_picker.js on lines 85..92
    app/javascript/src/locomotive/editor/inputs/url.js on lines 63..70

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

    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

    Method set_slug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def set_slug
              self._slug = self._label.dup if self._slug.blank? && self._label.present?
    
              if self._slug.present?
                # we can't rely on the self.site property yet (brand new entry for instance)
    Severity: Minor
    Found in app/models/locomotive/concerns/content_entry/slug.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 update_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_all(attributes)
          each_metafield(attributes) do |namespace, name, value|
            next unless field = site.find_metafield(name)
    
            if field['localized']
    Severity: Minor
    Found in app/services/locomotive/site_metafields_service.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 current_site_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def current_site_url
          if current_site.domains.blank?
            preview_url(current_site)
          else
            protocol = current_site.redirect_to_https? ? 'https' : 'http'
    Severity: Minor
    Found in app/helpers/locomotive/dashboard_helper.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 to_json has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_json
            add_authenticated_header
    
            if get?
              add_pagination_header if resource.respond_to?(:total_pages)
    Severity: Minor
    Found in lib/locomotive/action_controller/responder.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 create_api_token has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

              def create_api_token(email, password, api_key)
                if api_key.present?
                  account = self.where(api_key: api_key).first
    
                  raise 'The API key is invalid.' if account.nil?
    Severity: Minor
    Found in app/models/locomotive/concerns/account/api_key.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 persist_missing_translations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def persist_missing_translations(site, translations)
              new_translations = []
    
              translations.each do |attributes|
                if existing = site.translations.where(key: attributes[:key]).first
    Severity: Minor
    Found in lib/locomotive/steam/middlewares/missing_translations.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

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

      return api.loadSectionHTML(section, sectionContent)
      .then(html => {
        Preview.updateSection(_window, section, html);
    
        Preview.selectSection(_window, section, blockId);
    Severity: Minor
    Found in app/javascript/src/locomotive/editor/actions/section_actions.js and 1 other location - About 50 mins to fix
    app/javascript/src/locomotive/editor/actions/section_block_actions.js on lines 16..20

    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

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

      return api.loadSectionHTML(section, sectionContent)
        .then(html => {
          Preview.updateSection(_window, section, html);
          Preview.selectSection(_window, section, blockId);
        });
    app/javascript/src/locomotive/editor/actions/section_actions.js on lines 33..38

    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

        return [this.props.preset.type, this.props.category.id, this.props.preset.id].join('-');
    app/javascript/src/locomotive/editor/views/sections/gallery/index.js on lines 29..29

    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

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

        return [this.state.preset.type, this.state.category.id, this.state.preset.id].join('-');
    app/javascript/src/locomotive/editor/views/sections/gallery/preset.js on lines 16..16

    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

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

            def value_from_type(type, value, options)
              case type
              when :file
                value.blank? ? '' : value.guess_url(options[:host])
              when :belongs_to
    Severity: Minor
    Found in app/models/locomotive/concerns/content_entry/csv.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 class_names has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def class_names
              base = ['page']
              base << (children? ? 'node' : 'leaf')
              base << (published? ? 'published' : 'unpublished')
              base << (index_or_not_found? ? 'fixed' : '') if children?
    Severity: Minor
    Found in app/helpers/locomotive/shared/pages_helper.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 load_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_page
          page_id, content_entry_id = params[:page_id].split('-')
          content_entry_id ||= params[:content_entry_id]
    
          @page = current_site.pages.find(page_id).tap do |page|
    Severity: Minor
    Found in app/controllers/locomotive/page_content_controller.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

    Severity
    Category
    Status
    Source
    Language