SpontaneousCMS/spontaneous

View on GitHub

Showing 261 of 342 total issues

Method setup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def self.setup(options = {})
      config_level = (SPOT_LOG_LEVEL || Spontaneous.env || :production).to_sym # need this for SPOT_LOG_LEVEL
      config = Config[config_level] || Config[:production]                     # default to a production level
      stream = \
        if logfile = options[:logfile]
Severity: Minor
Found in lib/spontaneous/logger.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 Page has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Spontaneous.Page = (function($, S) {
    var dom = S.Dom, user = S.User;

    var Page = new JS.Class(Spontaneous.Content, {
        initialize: function(content) {
Severity: Minor
Found in application/js/page.js - About 1 hr to fix

    Function appendEntries has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            appendEntries: function(entries) {
                // only use dynamic loading for page boxes
                var entry_total = this.entries().length, attached = 0;
                if (this.level() === 0) {
                    var availableHeight = S.ContentArea.height() - entries.position().top;
    Severity: Minor
    Found in application/js/views/box_view.js - About 1 hr to fix

      Function User has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Spontaneous.User = (function($, S) {
          var ajax = S.Ajax;
      
          var User = new JS.Class({
              initialize: function(user_data) {
      Severity: Minor
      Found in application/js/user.js - About 1 hr to fix

        Function view has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                view: function() {
                    var self = this;
                    var user = this.user;
                    var wrap = dom.div();
                    var form = dom.form({method: 'post', action: ajax.request_url('/users/'+ user.get('id'))});
        Severity: Minor
        Found in application/js/meta_view/user_admin.js - About 1 hr to fix

          Function update has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      update: function(percent) {
                          this._indeterminate = false;
          
                          percent = Math.max(0.1, parseFloat(percent)); // always show something...
                          this._percent = percent;
          Severity: Minor
          Found in application/js/progress.js - About 1 hr to fix

            Method belongs_to_content has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def belongs_to_content(name, opts = {})
                      opts[:association]    = :many_to_one
                      opts[:dataset_method] = "#{name}_dataset"
                      opts[:add_method]     = "#{name}="
                      opts[:load_method]    = "load_#{opts[:association]}_association".to_sym
            Severity: Minor
            Found in lib/spontaneous/data_mapper/content_model/associations.rb - About 1 hr to fix

              Function open has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      open: function(instance) {
                          if (this._open || !instance) { return; }
                          this._instance = instance;
                          instance.manager = this;
                          $('body').css('overflow', 'hidden');
              Severity: Minor
              Found in application/js/dialogue.js - About 1 hr to fix

                Function panel has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        panel: function() {
                            var wrapper = dom.div(['entry-wrap', this.fields_class(), this.alias_class(), this.depth_class(), this.visibility_class(), this.boxes_class()]);
                            var contents = dom.div('.entry-contents');
                
                            var modification = new S.ModificationStatusPanel(this.content);
                Severity: Minor
                Found in application/js/views/piece_view.js - About 1 hr to fix

                  Method sync_to_revision has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def sync_to_revision(revision, origin=false)
                        # 'publish' is a lock to make sure the duplication doesn't cross
                        # page boundaries unless that's necessary (such as in the case
                        # of a page addition)
                        publish = origin || !page?
                  Severity: Minor
                  Found in lib/spontaneous/model/core/publishing.rb - About 1 hr to fix

                    Method validate! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def validate!
                            begin
                              validate_schema
                            rescue Spontaneous::SchemaModificationError => e
                              changes = e.modification
                    Severity: Minor
                    Found in lib/spontaneous/schema.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 next has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        next: function() {
                            if (this.pending.length === 0) {
                                this.container.className = 'loaded';
                                this.remove();
                                Spontaneous.onload();
                    Severity: Minor
                    Found in application/js/require.js - About 1 hr to fix

                      Method ask_user_details has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def ask_user_details(defaults = {}, users)
                              attrs = {}
                              level = nil
                              width = 14
                              valid_login = /^[a-z0-9_]{3,}$/
                      Severity: Minor
                      Found in lib/spontaneous/cli/user.rb - About 1 hr to fix

                        Function test_field_versions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                test_field_versions: function(target, fields, success, failure) {
                                    var version_data = {}, modified = 0;
                                    for (var i = 0, ii = fields.length; i < ii; i++) {
                                        var field = fields[i], key = '[fields]['+field.schema_id()+']';
                                        if (field.is_modified()) {
                        Severity: Minor
                        Found in application/js/ajax.js - About 1 hr to fix

                          Method safe_load has 38 lines of code (exceeds 25 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 1 hr to fix

                            Function Services has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            Spontaneous.Services = (function($, S) {
                                var dom = S.Dom;
                                var instance = new JS.Singleton({
                                    include: S.Properties,
                                    loaded: function(serviceData) {
                            Severity: Minor
                            Found in application/js/services.js - About 1 hr to fix

                              Function open_uid_editor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      open_uid_editor: function() {
                                          this.panel.velocity({'height': '+=14'}, { duration: 200, complete: function() {
                                              var view = $('h3', this.panel), edit = $('.edit', this.panel);
                                              view.hide();
                                              edit.hide().empty();
                              Severity: Minor
                              Found in application/js/views/page_view.js - About 1 hr to fix

                                Method has_many_content has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        def has_many_content(name, opts = {})
                                          opts[:association]    = :one_to_many
                                          opts[:dataset_method] = "#{name}_dataset"
                                          opts[:load_ps_method] = "load_#{name}_association_prepared_statement".to_sym
                                          opts[:ps_method]      = "#{name}_prepared_statement".to_sym
                                Severity: Minor
                                Found in lib/spontaneous/data_mapper/content_model/associations.rb - About 1 hr to fix

                                  Method schema_validate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                        def schema_validate(schema)
                                          if schema_id.nil?
                                            schema.missing_id!(:type, self)
                                          else
                                            # only need to check internal consistency if class already existed
                                  Severity: Minor
                                  Found in lib/spontaneous/model/core/schema_hierarchy.rb - About 1 hr to fix

                                    Method open_console has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        def open_console
                                          prepare! :console
                                    
                                          ARGV.clear
                                          ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
                                    Severity: Minor
                                    Found in lib/spontaneous/cli/console.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language