withassociates/slices

View on GitHub

Showing 74 of 74 total issues

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

  attach: function() {
    $('#placeholder-' + this.id).replaceWith(this.el);
    this.render();
  },
Severity: Major
Found in app/assets/javascripts/slices/app/views/date_field_view.js and 3 other locations - About 35 mins to fix
app/assets/javascripts/slices/app/views/composer_view.js on lines 42..45
app/assets/javascripts/slices/app/views/radio_field_view.js on lines 43..46
app/assets/javascripts/slices/app/views/token_field_view.js on lines 84..87

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

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

      x: $(this.el).offset().left + ($(this.el).width() / 2),
Severity: Minor
Found in app/assets/javascripts/slices/app/views/attachment_view.js and 1 other location - About 35 mins to fix
app/assets/javascripts/slices/app/views/attachment_view.js on lines 96..96

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

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

  def sanitize(filename)
    file.send(:cleanup_filename, filename).tap do |name|
      if self.file && self.file.original_filename
        extension = normalized_extension
        name << extension unless name.ends_with?(extension)
Severity: Minor
Found in app/models/asset.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

Function Page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  function () {

    var settings,
        pageId,
        pageData,
Severity: Minor
Found in app/assets/javascripts/slices/app/models/page.js - 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

Avoid too many return statements within this function.
Open

        return t.all({ total: total, count: count });
Severity: Major
Found in app/assets/javascripts/slices/app/views/asset_library_view.js - About 30 mins to fix

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

          beforeStart: _.bind(function(e, ui) {
            list.freezeHeight();
            window.autoscroll.start();
          }, this),
    Severity: Minor
    Found in app/assets/javascripts/slices/app/views/composer_view.js and 1 other location - About 30 mins to fix
    app/assets/javascripts/slices/app/views/composer_view.js on lines 69..72

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

    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

    Avoid too many return statements within this function.
    Open

      return bytes + 'b';
    Severity: Major
    Found in app/assets/javascripts/slices/lib/human_file_size.js - About 30 mins to fix

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

            stop: _.bind(function(e, ui) {
              list.thawHeight();
              window.autoscroll.stop();
            }, this),
      Severity: Minor
      Found in app/assets/javascripts/slices/app/views/composer_view.js and 1 other location - About 30 mins to fix
      app/assets/javascripts/slices/app/views/composer_view.js on lines 64..67

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

      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

      Avoid too many return statements within this function.
      Open

          return inp.val();
      Severity: Major
      Found in app/assets/javascripts/slices/app/helpers/get_value.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return t.some({ total: total, count: count });
        Severity: Major
        Found in app/assets/javascripts/slices/app/views/asset_library_view.js - About 30 mins to fix

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

            def show
              page = Page.find(params[:id])
              @page = presenter_class(page.class).new(page)
              @layout = Layout.new(page.layout)
          
          
          Severity: Minor
          Found in app/controllers/admin/pages_controller.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

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

            def secondary_navigation(options = {})
              name = options.fetch('id') { 'secondary_navigation' }
              cache cache_key_for_navigation(name) do
                benchmark 'Rendered secondary_navigation' do
                  secondary_ancestors = (@page.ancestors[-2] || @page).navigable_children
          Severity: Minor
          Found in app/helpers/navigation_helper.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

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

            def link_image_if_linkable(link, image, size, options = {})
              image_options = options.has_key?(:image_options) ? options.delete(:image_options) : {}
              image = image_if_present(image, size, image_options)
              if image.present?
                if link.present?
          Severity: Minor
          Found in app/helpers/assets_helper.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

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

            def index
              admins = Admin.all
              if params.has_key?(:search) && params[:search].present?
                admins = admins.text_search(params[:search])
              end
          Severity: Minor
          Found in app/controllers/admin/admins_controller.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

          Severity
          Category
          Status
          Source
          Language