SpontaneousCMS/spontaneous

View on GitHub

Showing 342 of 342 total issues

Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(site, owner, filename, digest, headers = {})
Severity: Minor
Found in lib/spontaneous/media/file.rb - About 35 mins to fix

    Method store has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def store(revision, partition, path, template, transaction)
    Severity: Minor
    Found in lib/spontaneous/output/store/moneta.rb - About 35 mins to fix

      Method set has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def self.set(site, field, value, user, asynchronous = false)
      Severity: Minor
      Found in lib/spontaneous/field.rb - About 35 mins to fix

        Method update has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def self.update(site, content, params, user, asynchronous = false)
        Severity: Minor
        Found in lib/spontaneous/field.rb - About 35 mins to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(site, revision, pages, progress = Spontaneous::Publishing::Progress::Silent.new, user = nil)
          Severity: Minor
          Found in lib/spontaneous/publishing/transaction.rb - About 35 mins to fix

            Method store has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def store(revision, partition, key, template, transaction)
            Severity: Minor
            Found in lib/spontaneous/output/store/file.rb - About 35 mins to fix

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

                  def redirect(location, redirect_code=:temporary)
                    if String === location
                      destination = @site[location]
                      location = destination.path if destination and destination.respond_to?(:path)
                    else
              Severity: Minor
              Found in lib/spontaneous/rack/page_controller.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 content_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def content_type(type, params={})
                      default   = params.delete :default
                      mime_type = mime_type(type) || default
                      fail "Unknown media type: %p" % type if mime_type.nil?
                      mime_type = mime_type.dup
              Severity: Minor
              Found in lib/spontaneous/rack/public.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 PagePieceView has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              Spontaneous.Views.PagePieceView = (function($, S) {
                  'use strict';
                  var dom = S.Dom;
              
                  var PagePieceView = new JS.Class(Spontaneous.Views.PieceView, {
              Severity: Minor
              Found in application/js/views/page_piece_view.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def call(env)
                      return @app.call(env) unless ALLOWED_METHODS.include?(env[S::REQUEST_METHOD])
                      orig_path = env['PATH_INFO']
                      found = nil
                      @try.each do |path|
              Severity: Minor
              Found in lib/spontaneous/rack/static.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 update_serialized_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update_serialized_fields(fields = nil)
                    if fields.nil?
                      @field_set.serialize_db
                    else
                      field_store = (self.field_store || []).dup
              Severity: Minor
              Found in lib/spontaneous/model/core/fields.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 geolocate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def geolocate(address)
                    return {} if address.blank?
                    url = "http://maps.google.com/maps/api/geocode/json?address=#{URI.escape(address)}&sensor=false"
              
                    response = open(url).read rescue "{}"
              Severity: Minor
              Found in lib/spontaneous/field/location.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 safe_stat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def safe_stat(file)
                      return unless file
                      stat = ::File.stat(file)
                      return file, stat if stat.file?
                    rescue Errno::ENOENT, Errno::ENOTDIR
              Severity: Minor
              Found in lib/spontaneous/loader.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def load(id, reference)
                    @instance_lock.synchronize do
                      unless instance = @instances[id]
                        instance = UID.new(self, id, reference)
                        # check to make sure that the uid is valid first
              Severity: Minor
              Found in lib/spontaneous/schema/uid_map.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 create_visibility_modifications has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create_visibility_modifications
                    # We only want to record visibility changes that originate from user action, not ones propagated
                    # from higher up the tree, hence the check against the hidden_origin.
                    return false unless changed_columns.include?(:hidden) && hidden_origin.nil?
                    if (previous_modification = local_modifications.detect { |mod| mod.type == :visibility })
              Severity: Minor
              Found in lib/spontaneous/model/core/modifications.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 create_slug_modifications has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create_slug_modifications
                    change = changes_to_cascade[:slug]
                    return false if change.nil?
                    old_slug, new_slug = change.old_value, self[:slug]
                    return false if old_slug.nil? # ignore first change of slug from nil to provided or generated
              Severity: Minor
              Found in lib/spontaneous/model/core/modifications.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 named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def named(name)
                    key = name.to_sym
                    return @store[key] if @store.key?(key)
                    value = (superset? ? superset.named(name) : nil)
                    return value unless value.nil?
              Severity: Minor
              Found in lib/spontaneous/collections/prototype_set.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 propagate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def propagate
                      return if owner.nil?
                      content = owner
              
                      content.mapper.clean_scope! do
              Severity: Minor
              Found in lib/spontaneous/model/core/content_hash.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 create_content_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.create_content_table(db, source_table, dest_table_name)
                  # sqlite doesn't like it if you create a table with no columns
                  # so hard-code the id column (but don't make it a pk because the
                  # unique constraint isn't useful at this stage)
                  schema = db.schema(source_table).dup.delete_if { |col, opts| col == :id }
              Severity: Minor
              Found in lib/spontaneous/publishing/revision.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

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

                          var drag_enter = function(event) {
                              stopEvent(event);
                              $(this).addClass('drop-active');
                              return false;
                          }.bind(dropper);
              Severity: Major
              Found in application/js/field/file.js and 3 other locations - About 35 mins to fix
              application/js/field/file.js on lines 66..70
              application/js/field/file.js on lines 77..81
              application/js/field/file.js on lines 234..238

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

              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