SpontaneousCMS/spontaneous

View on GitHub

Showing 261 of 342 total issues

Method create_instance_class has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def create_instance_class
      Class.new(box_base_class).tap do |instance_class|
        # doing this means we get proper names for the anonymous box classes
        owner.const_set("#{name.to_s.camelize}Box", instance_class)
        box_owner = owner
Severity: Minor
Found in lib/spontaneous/prototypes/box_prototype.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 before_save has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def before_save
      if owner
        self.page = owner.page if page.nil?
        if page?
          self.depth = parent ? ((parent.depth || 0) + 1) : 0
Severity: Minor
Found in lib/spontaneous/model/core/entries.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 update_navigation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        update_navigation: function(location) {
            var nodes = [];
            // var location = this.get('location');
            var $location_bar = this.location;
            if (typeof location.ancestors === 'undefined') {
Severity: Minor
Found in application/js/top_bar.js - About 1 hr to fix

    Function pageAliasesPanel has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            pageAliasesPanel: function() {
                var $wrap = dom.div('.page-aliases');
                var aliases = this.page.content.aliases;
                if (aliases.length === 0) {
                    return $wrap;
    Severity: Minor
    Found in application/js/views/page_view.js - About 1 hr to fix

      Function pageAliasesPanel has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              pageAliasesPanel: function() {
                  var $wrap = dom.div('.page-aliases');
                  var aliases = this.page.content.aliases;
                  if (aliases.length === 0) {
                      return $wrap;
      Severity: Minor
      Found in application/js/views/page_view.js - About 1 hr to fix

        Function complete has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    this.panel.velocity({'height': '+=14'}, { duration: 200, complete: function() {
                        var view = $('h3', this.panel), edit = $('.edit', this.panel);
                        view.hide();
                        edit.hide().empty();
                        var input = dom.input({'type':'text', 'autofocus':'autofocus'}).val(this.page.content.uid).select();
        Severity: Minor
        Found in application/js/views/page_view.js - About 1 hr to fix

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

            Method run! has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.run!(site, options={})
                  host = options["host"] || Spontaneous::Site.config.host || "0.0.0.0"
                  port = options["port"] || Spontaneous::Site.config.port || 2012
                  adapter = options["adapter"] || Spontaneous::Site.config.adapter
            
            
            Severity: Minor
            Found in lib/spontaneous/server.rb - About 1 hr to fix

              Function StatusBar has 33 lines of code (exceeds 25 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 1 hr to fix

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

                        view: function() {
                            var __view = this, w = dom.div('.pop-insert-link'), text_input, url_input;
                            var input = function(label, value, type) {
                                var l, i = dom[(type || 'input')]({'type':'text'}).keypress(function(event) {
                                    if (event.charCode === 13) {
                Severity: Minor
                Found in application/js/field/markdown.js - About 1 hr to fix

                  Method smush! has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def smush!
                        p src_file
                        return if ::Spontaneous.development?
                        ext = @format.nil? ? File.extname(src_file) : ".#{@format}"
                        id = [Time.now.to_i, Time.now.usec].join('-')
                  Severity: Minor
                  Found in lib/spontaneous/utils/smush_it.rb - About 1 hr to fix

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

                            open: function(event) {
                                event.preventDefault();
                                var view = this.view;
                                var location = view.attach_to();
                                var wrapper = dom.div('.pop-over');
                    Severity: Minor
                    Found in application/js/popover.js - About 1 hr to fix

                      Method belongs_to_content has a Cognitive Complexity of 11 (exceeds 5 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

                      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 slice_between has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def slice_between(&b)
                          Enumerator.new {|y|
                            first = true
                            buf = []
                            prev = nil
                      Severity: Minor
                      Found in lib/spontaneous/extensions/enumerable.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 listEntry has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              listEntry: function(user) {
                                  var self = this;
                                  var row = dom.div('.user');
                                  row.attr('id', 'user-admin-' + user.get('id'));
                                  var cells = ['name', 'level'].map(function(attr) {
                      Severity: Minor
                      Found in application/js/meta_view/user_admin.js - About 1 hr to fix

                        Function element has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                element: function(cancelCallback) {
                                    var self = this;
                                    var levels = Level.levels;
                                    var currentLevel = Level.get(this.user.get('level')) || Level.defaultLevel();
                                    var outer = dom.div('.level-select');
                        Severity: Minor
                        Found in application/js/meta_view/user_admin.js - About 1 hr to fix

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

                                  panel: function() {
                                      var self = this;
                                      var wrapper = dom.div(['entry-wrap page no-boxes', self.alias_class(), self.fields_class(), self.depth_class(), self.visibility_class()]);
                                      var contents = dom.div('.entry-contents');
                                      var inside = dom.div('.entry-inner');
                          Severity: Minor
                          Found in application/js/views/page_piece_view.js - About 1 hr to fix

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

                                    panel: function() {
                                        if (this._panel) {
                                            return this._panel;
                                        }
                                        var panel = dom.div('#page-content');
                            Severity: Minor
                            Found in application/js/views/page_view.js - About 1 hr to fix

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

                                      aboveUserAttributes: function() {
                                          var self = this;
                                          var user = this.user;
                                          var admin = dom.div('.admin');
                                          p = dom.p('.enabled');
                              Severity: Minor
                              Found in application/js/meta_view/user_admin.js - About 1 hr to fix

                                Method reload! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def reload!
                                        changed_files = []
                                        rotation do |file, mtime|
                                          # Retrive the last modified time
                                          new_file = mtimes[file].nil?
                                Severity: Minor
                                Found in lib/spontaneous/loader.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language