SpontaneousCMS/spontaneous

View on GitHub

Showing 342 of 342 total issues

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

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

                      var drag_enter = function(event) {
                          event.stopPropagation();
                          event.preventDefault();
                          $(this).addClass('drop-active');
                          return false;
          Severity: Major
          Found in application/js/field/image.js and 3 other locations - About 1 hr to fix
          application/js/field/image.js on lines 198..203
          application/js/field/image.js on lines 368..373
          application/js/field/image.js on lines 381..386

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

          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 4 locations. Consider refactoring.
          Open

                      var drag_leave = function(event) {
                          event.stopPropagation();
                          event.preventDefault();
                          $(this).removeClass('drop-active');
                          return false;
          Severity: Major
          Found in application/js/field/image.js and 3 other locations - About 1 hr to fix
          application/js/field/image.js on lines 185..190
          application/js/field/image.js on lines 198..203
          application/js/field/image.js on lines 368..373

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

          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 4 locations. Consider refactoring.
          Open

                      var drag_leave = function(event) {
                          event.stopPropagation();
                          event.preventDefault();
                          $(this).removeClass('drop-active');
                          return false;
          Severity: Major
          Found in application/js/field/image.js and 3 other locations - About 1 hr to fix
          application/js/field/image.js on lines 185..190
          application/js/field/image.js on lines 368..373
          application/js/field/image.js on lines 381..386

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

          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 4 locations. Consider refactoring.
          Open

                      var drag_enter = function(event) {
                          event.stopPropagation();
                          event.preventDefault();
                          $(this).addClass('drop-active');
                          return false;
          Severity: Major
          Found in application/js/field/image.js and 3 other locations - About 1 hr to fix
          application/js/field/image.js on lines 185..190
          application/js/field/image.js on lines 198..203
          application/js/field/image.js on lines 381..386

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

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

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

                          for (var i = 0, ii = this.completed.length; i < ii; i++) {
                              completed += this.completed[i].total();
                          }
              Severity: Major
              Found in application/js/upload_manager.js and 1 other location - About 1 hr to fix
              application/js/upload_manager.js on lines 137..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 58.

              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

                          for (var i = 0, ii = this.completed.length; i < ii; i++) {
                              total += this.completed[i].total();
                          }
              Severity: Major
              Found in application/js/upload_manager.js and 1 other location - About 1 hr to fix
              application/js/upload_manager.js on lines 150..152

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

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

                      Method include_page? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def include_page?(page)
                            return true unless page.page?
                            unless @exclude_pages.nil?
                              rejected = @exclude_pages.any? { |selector| match_page(selector, page) }
                              return false if rejected
                      Severity: Minor
                      Found in lib/spontaneous/search/index.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 fields has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def fields
                            field_lists = Hash.new { |h, k| h[k] = [] }
                            # collect all the definitions for a particular field or group
                            all_types.select { |t| include_type?(t) }.each do |type|
                              type.field_prototypes.each do |prototype|
                      Severity: Minor
                      Found in lib/spontaneous/search/index.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

                      Severity
                      Category
                      Status
                      Source
                      Language