SpontaneousCMS/spontaneous

View on GitHub

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

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

              save_uid: function(uid) {
                  Spontaneous.Ajax.put(['/page',this.page.id(), 'uid'].join('/'), {'uid':uid}, this.uid_save_complete.bind(this));
              },
      Severity: Major
      Found in application/js/views/page_view.js and 1 other location - About 1 hr to fix
      application/js/views/page_view.js on lines 365..367

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

      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

              save: function(slug) {
                  Spontaneous.Ajax.put(['/page',this.page.id(), 'slug'].join('/'), {'slug':slug}, this.save_complete.bind(this));
              },
      Severity: Major
      Found in application/js/views/page_view.js and 1 other location - About 1 hr to fix
      application/js/views/page_view.js on lines 260..262

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

      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

              init: function(container) {
                  this.iframe = dom.iframe('#preview_pane', {'src':'about:blank'});
                  this.iframe.hide();
                  container.append(this.iframe);
                  return this;
      Severity: Major
      Found in application/js/preview.js and 1 other location - About 1 hr to fix
      application/js/services.js on lines 21..26

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

      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

              init: function(container) {
                  this.iframe = dom.iframe('#services_pane', {'src':'about:blank'});
                  this.iframe.hide();
                  container.append(this.iframe);
                  return this;
      Severity: Major
      Found in application/js/services.js and 1 other location - About 1 hr to fix
      application/js/preview.js on lines 18..23

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

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

                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

                  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

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

                                var comparator = function(a, b) {
                                    var at = a.title, bt = b.title;
                                    if (at > bt) { return 1; }
                                    if (at < bt) { return -1; }
                                    return 0;
                    Severity: Major
                    Found in application/js/add_alias_dialogue.js and 1 other location - About 1 hr to fix
                    application/js/top_bar.js on lines 15..20

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

                    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

                        var slugComparator = function(a, b) {
                            var at = a.slug, bt = b.slug;
                            if (at > bt) { return 1; }
                            if (at < bt) { return -1; }
                            return 0;
                    Severity: Major
                    Found in application/js/top_bar.js and 1 other location - About 1 hr to fix
                    application/js/add_alias_dialogue.js on lines 239..244

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

                    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

                    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

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

                                    var labels = dom.div('.image-field-conflict.labels.differences'),
                                        outer = dom.div(),
                                        image_outer = dom.div('.image-field-conflict.changes.differences'),
                                        original = dom.div('.original.diff'),
                                        edited = dom.div('.final.diff');
                        Severity: Major
                        Found in application/js/field/image.js and 1 other location - About 1 hr to fix
                        application/js/field/string.js on lines 13..13

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language