withassociates/slices

View on GitHub

Showing 38 of 74 total issues

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

  def self.make(attributes = {})
    attributes = attributes.symbolize_keys
    parent = parent_from_attributes(attributes)
    attributes[:path] ||= path_from_attributes(attributes, parent)

Severity: Minor
Found in app/models/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 find_all_slices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.find_all_slices
      slices = []

      Dir.glob(File.join(Rails.root, 'app/slices/**/*_slice.rb')).each do |path|

Severity: Minor
Found in lib/slices/available_slices.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 update_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def update_attributes(attributes)
      [:slices, :set_slices].each do |embed_name|
        next if attributes[embed_name].nil?

        attributes[embed_name] = attributes[embed_name].map { |slice_attributes|
Severity: Minor
Found in lib/slices/has_slices.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

Function enableContainerSelect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function enableContainerSelect(slice, sliceBlock) {

      var potentialContainers = {};

      _.each(slices.availableContainers, function(container, machineName) {
Severity: Minor
Found in app/assets/javascripts/slices/app/slices.js - About 1 hr to fix

    Function ordinal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      ordinal : function (number) {
        var b = number % 10;
        return (~~ (number % 100 / 10) === 1) ? 'th' :
          (b === 1) ? 'st' :
          (b === 2) ? 'nd' :
    Severity: Minor
    Found in app/assets/javascripts/slices/lib/moment.js - 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_attributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def write_attributes(attrs)
        attrs = attrs.symbolize_keys
        self.embedded_relations.each do |field, metadata|
          field = field.to_sym
          next unless attrs.has_key?(field)
    Severity: Minor
    Found in app/models/slice.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

    Function display has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      display: function() {
        if (this.value) {
          var self = this;
          return this.displayTemplate({
            date: this.value.format('dddd D MMMM YYYY'),
    Severity: Minor
    Found in app/assets/javascripts/slices/app/views/date_field_view.js - 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

    Function render_pagination has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        render_pagination: function() {
          $pagination = this.$('#pagination');
          if (this.collection.total_pages === 1) {
            $pagination.empty();
            return
    Severity: Minor
    Found in app/assets/javascripts/slices/app/backbones/generic.js - 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

    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

    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

    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

      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

        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

          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

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