SpontaneousCMS/spontaneous

View on GitHub

Showing 261 of 342 total issues

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

Avoid too many return statements within this method.
Open

        return template
Severity: Major
Found in lib/spontaneous/output/template/renderer.rb - About 30 mins to fix

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

            def save
              id = nil
              saved = false
              trigger_hook(:before_save) do
                if new?
    Severity: Minor
    Found in lib/spontaneous/data_mapper/content_model.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

    Function StatusBar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Spontaneous.StatusBar = (function($, S) {
        var dom = S.Dom;
    
        var StatusBar = {
            showing: false,
    Severity: Minor
    Found in application/js/status_bar.js - 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

    Function FieldPreview has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Spontaneous.FieldPreview = (function($, S) {
        var dom = S.Dom;
    
        var FieldPreview = new JS.Class({
            initialize: function(view, wrap_id, listView) {
    Severity: Minor
    Found in application/js/field_preview.js - 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 host_url_mapper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def host_url_mapper(host)
          uri = URI.parse(host)
          lambda { |path|
            return path if path.blank?
            begin
    Severity: Minor
    Found in lib/spontaneous/media/store/cloud.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(options={})
          @buffer            = []
          @auto_flush        = options.has_key?(:auto_flush) ? options[:auto_flush] : true
          @level             = options[:log_level] ? Levels[options[:log_level]] : Levels[:debug]
          @log               = options[:stream]  || $stdout
    Severity: Minor
    Found in lib/spontaneous/logger.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 script_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def script_list(scripts)
          scripts.map do |script|
            script = "#{script}.js" unless script =~ /\.js$/
            src = script_url(script)
            size = 0
    Severity: Minor
    Found in lib/spontaneous/rack/back/helpers.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 layout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def layout(name = nil, options = {}, &block)
            name = name.to_sym unless name.blank?
            if block_given?
              layout_procs[name] = block
            else
    Severity: Minor
    Found in lib/spontaneous/model/page/layouts.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 box has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def box(name, options = {}, &block)
            name = name.to_sym
            prototype = nil
            options[:group] = @box_group if @box_group
    
    
    Severity: Minor
    Found in lib/spontaneous/model/core/boxes.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 full_const_get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def full_const_get(name)
            list = name.split("::")
            list.shift if list.first.blank?
            obj = self
            list.each do |x|
    Severity: Minor
    Found in lib/spontaneous/extensions/object.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 copy_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def copy_file(existing_file, dest_path)
          if existing_file.respond_to?(:read)
            # Re-open the file because it's been modified on disk by the optimisation process
            # and if we don't re-open it the copy will take the unmodified version
            File.open(existing_file.path, "rb") do |src|
    Severity: Minor
    Found in lib/spontaneous/media/store/local.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 place_in_page_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def place_in_page_tree
          if parent_id.nil?
            if __create_private_root? || content_model.has_root?
              make_private_root
            else
    Severity: Minor
    Found in lib/spontaneous/model/page/paths.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 user_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def user_table(users, hide_headers = false)
            columns = [:login, :name, :email, :level]
            users = ::Spontaneous::Permissions::User.all.map { |user|
              columns.map { |column| user.send(column) }
            }
    Severity: Minor
    Found in lib/spontaneous/cli/user.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 extract_content_length has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def extract_content_length(headers)
              headers.each do |key, value|
                if key.downcase == 'content-length'
                  return value.to_s == '0' ? '-' : value
                end
    Severity: Minor
    Found in lib/spontaneous/logger.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 check_styles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def check_styles
            @options[:styles] = [@options[:style]] if @options.key?(:style)
            if @options.key?(:styles) and styles = @options[:styles]
              styles.each do |s|
                if instance_class.find_named_style(s).nil?
    Severity: Minor
    Found in lib/spontaneous/model/box/allowed_types.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 authenticate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.authenticate(login, clear_password, ip_address = nil)
          if (user = self[login: login, disabled: false])
            authenticator = Spontaneous::Crypt.new(clear_password, user.crypted_password)
            if authenticator.valid?
              user.upgrade_authentication(authenticator) if authenticator.outdated?
    Severity: Minor
    Found in lib/spontaneous/permissions/user.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 expanded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def expanded(category)
          self[category].map do |path, glob|
            abs_path = expand_path(path)
            if abs_path.exist?
              abs_path += glob if glob
    Severity: Minor
    Found in lib/spontaneous/paths.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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def method_missing(method, *args)
            if target && respond_to_missing?(method)
              if block_given?
                target.__send__(method, *args, &Proc.new)
              else
    Severity: Minor
    Found in lib/spontaneous/model/core/aliases.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