SpontaneousCMS/spontaneous

View on GitHub

Showing 342 of 342 total issues

Function State has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Spontaneous.State = (function($, S) {
    var ajax = S.Ajax;

    var ContentState = new JS.Class({
        initialize: function(content) {
Severity: Major
Found in application/js/state.js - About 2 hrs to fix

    Function Types has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    Spontaneous.Types = (function($, S) {
        var ajax = S.Ajax
    , user = S.User
    , type_map = {};
    
    
    Severity: Minor
    Found in application/js/types.js - About 2 hrs 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 at_depth has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def at_depth(depth, opts = {})
          return root_at_depth(depth) if is_public_root? || is_private_root?
          parent_depth = [0, depth - 1].max
          parent = if (parent_depth == 0)
            public_root
    Severity: Minor
    Found in lib/spontaneous/model/page/page_tree.rb - About 2 hrs 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_html has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_html(opts={})
          default_attr = { src: src, alt: "" }
          attrs = Spontaneous::Field::Image.default_attributes.merge(opts)
    
          if template_params && template_params.length > 0 && template_params[0].is_a?(Hash)
    Severity: Minor
    Found in lib/spontaneous/media/image/renderable.rb - About 2 hrs 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_load has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def safe_load(file, mtime=nil)
            reload = mtime && mtime > mtimes[file]
    
            logger.debug "Reloading #{relativize_path(file)}" if reload
    
    
    Severity: Minor
    Found in lib/spontaneous/loader.rb - About 2 hrs 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 expand_selection has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            expand_selection: function(state) {
                var selected = (state.selection || ''), m, s, l, start = state.start, end = state.end, br = /\r?\n/, below = false;
                // detect & deal with the cursor being on the line below
                // (the one with the -'s or ='s)
                // TODO: deal with the case where the cursor is at the start of the =- line
    Severity: Major
    Found in application/js/field/markdown.js - About 2 hrs to fix

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

              find_path: function(path) {
                  if (this.location() && path === this.location().path) {
                      return this.location();
                  }
                  this.retrieve_with_progress('/map/path'+path, this.location_loaded.bind(this));
      Severity: Major
      Found in application/js/location.js and 1 other location - About 2 hrs to fix
      application/js/location.js on lines 134..139

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

      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

              find_id: function(id) {
                  if (this.location() && id === this.location().id) {
                      return this.location();
                  }
                  this.retrieve_with_progress('/map/'+id, this.location_loaded.bind(this));
      Severity: Major
      Found in application/js/location.js and 1 other location - About 2 hrs to fix
      application/js/location.js on lines 128..133

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

      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

      Class Style has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Style
          attr_reader :owner, :prototype
      
          def initialize(owner, prototype = nil)
            @owner, @prototype = owner, prototype
      Severity: Minor
      Found in lib/spontaneous/style.rb - About 2 hrs to fix

        Class Generator has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Generator
              attr_reader :modified_pages
        
              # Both revision & source_revision should be instances of Revision
              def initialize(revision)
        Severity: Minor
        Found in lib/spontaneous/publishing/revision.rb - About 2 hrs to fix

          Class AllowedType has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class AllowedType
                prepend Spontaneous::Model::Page::Singleton::AllowedTypeMethods
          
                attr_accessor :allow_subclasses
          
          
          Severity: Minor
          Found in lib/spontaneous/model/box/allowed_types.rb - About 2 hrs to fix

            Function Select has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Spontaneous.Field.Select = (function($, S) {
                'use strict';
            
                var dom = S.Dom
            , ajax = S.Ajax;
            Severity: Major
            Found in application/js/field/select.js - About 2 hrs to fix

              File loader.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'pathname'
              
              module Spontaneous
                class Loader
                  attr_reader :use_reloader, :load_paths
              Severity: Minor
              Found in lib/spontaneous/loader.rb - About 2 hrs to fix

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

                            for (var i = 0, ii = fields.length; i < ii; i++) {
                                var f = fields[i];
                                this.field_names.push(f.name);
                                this.field_prototypes[f.name] = f;
                            }
                Severity: Major
                Found in application/js/types.js and 1 other location - About 2 hrs to fix
                application/js/types.js on lines 45..49

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

                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

                            for (var i = 0, ii = fields.length; i < ii; i++) {
                                var f = fields[i];
                                this.field_names.push(f.name);
                                this.field_prototypes[f.name] = f;
                            }
                Severity: Major
                Found in application/js/types.js and 1 other location - About 2 hrs to fix
                application/js/types.js on lines 15..19

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

                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

                Function PopoverView has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Spontaneous.PopoverView = (function($, S) {
                    var dom = S.Dom;
                    var PopoverView = new JS.Class({
                        initialize: function() {
                            // should be over-ridden by subclasses
                Severity: Major
                Found in application/js/popover_view.js - About 2 hrs to fix

                  Method parse_response has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def parse_response(response)
                          case
                          when response.is_a?(site.model)
                            @page = response
                          when response.respond_to?(:to_str)
                  Severity: Minor
                  Found in lib/spontaneous/rack/public.rb - About 2 hrs 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 ContentArea has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Spontaneous.ContentArea = (function($, S) {
                      var dom = S.Dom;
                      var ContentArea = new JS.Singleton({
                          include: Spontaneous.Properties,
                  
                  
                  Severity: Minor
                  Found in application/js/content_area.js - About 2 hrs 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 add_allowed_types_bar has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          add_allowed_types_bar: function(position, insert_at) {
                              var allowed = this.box.allowed_types();
                              if (allowed.length === 0) { return ''; }
                              var _box = this
                  , allowed_bar = dom.div('.slot-addable')
                  Severity: Major
                  Found in application/js/views/box_view.js - About 2 hrs to fix

                    File file.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    // console.log('Loading FileField...')
                    Spontaneous.Field.File = (function($, S) {
                        var dom = S.Dom;
                        var FileField = new JS.Class(Spontaneous.Field.String, {
                            selected_files: false,
                    Severity: Minor
                    Found in application/js/field/file.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language