SpontaneousCMS/spontaneous

View on GitHub

Showing 342 of 342 total issues

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][1];
        }
Severity: Major
Found in application/js/require.js and 1 other location - About 1 hr to fix
application/js/require.js on lines 46..48

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

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

module Spontaneous::Output::Helpers
  module ScriptHelper

    extend self

Severity: Minor
Found in lib/spontaneous/output/helpers/script_helper.rb and 1 other location - About 1 hr to fix
lib/spontaneous/output/helpers/stylesheet_helper.rb on lines 5..25

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

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

module Spontaneous::Output::Helpers
  module StylesheetHelper
    extend self

    def stylesheet_helper
Severity: Minor
Found in lib/spontaneous/output/helpers/stylesheet_helper.rb and 1 other location - About 1 hr to fix
lib/spontaneous/output/helpers/script_helper.rb on lines 5..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 47.

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

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

    var Editing = new JS.Singleton({
        include: Spontaneous.Properties,
Severity: Minor
Found in application/js/editing.js - About 55 mins 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 render_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def render_path(path)
        @template_params = {}
        find_page!(path)

        response = catch(:halt) do
Severity: Minor
Found in lib/spontaneous/rack/public.rb - About 55 mins 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 render! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def render!(output, params, parent_context)
      # See `spontaneous/output/store/transaction.rb` for the `store_output`
      # clauses that explain this reasoning...
      if output.protected?
        # We can be sure that if the output says it's protected then it'll be
Severity: Minor
Found in lib/spontaneous/output/template/renderer.rb - About 55 mins 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 find_target has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def find_target
        case @category
        when :type
          begin
            @name.constantize
Severity: Minor
Found in lib/spontaneous/schema/uid.rb - About 55 mins 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 2 locations. Consider refactoring.
Open

        width: function() {
            if (this.data.values && this.currentValue()) {
                return this.currentValue().width;
            }
            return 0;
Severity: Minor
Found in application/js/field/image.js and 1 other location - About 55 mins to fix
application/js/field/image.js on lines 258..263

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

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

        height: function() {
            if (this.data.values && this.currentValue()) {
                return this.currentValue().height;
            }
            return 0;
Severity: Minor
Found in application/js/field/image.js and 1 other location - About 55 mins to fix
application/js/field/image.js on lines 252..257

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

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

  class ApplicationAssetServer
    CONTENT_TYPE = "Content-Type".freeze

    def initialize(environment, charset = "UTF-8")
      @environment, @charset = environment, charset
Severity: Minor
Found in lib/spontaneous/rack/application_asset_server.rb and 1 other location - About 50 mins to fix
lib/spontaneous/rack/asset_server.rb on lines 5..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 43.

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

  class AssetServer
    CONTENT_TYPE = "Content-Type".freeze

    def initialize(environment, charset = "UTF-8")
      @environment, @charset = environment, charset
Severity: Minor
Found in lib/spontaneous/rack/asset_server.rb and 1 other location - About 50 mins to fix
lib/spontaneous/rack/application_asset_server.rb on lines 5..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 43.

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 _draw_square has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

            _draw_square: function(ctx, c, r1, r2, a, p) {
Severity: Minor
Found in application/js/progress.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            for (i = startPosition - 1; i > position; i--) {
                                targets.push(allTargets[i]);
                            }
    Severity: Major
    Found in application/js/add_alias_dialogue.js - About 45 mins to fix

      Function ConflictedFieldDialogue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      Spontaneous.ConflictedFieldDialogue = (function($, S) {
          var dom = S.Dom, Dialogue = Spontaneous.Dialogue;
      
          var ConflictedFieldDialogue = new JS.Class(Dialogue, {
              initialize: function(parent_view, conflicted_fields) {
      Severity: Minor
      Found in application/js/conflicted_field_dialogue.js - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 _draw_rounded has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  _draw_rounded: function(ctx, c, r1, r2, a, p) {
      Severity: Minor
      Found in application/js/progress.js - About 45 mins to fix

        Method fix_schema has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def fix_schema(error)
                modification = error.modification
                actions = modification.actions
                say(actions.description, :red)
                say("Please choose one of the solutions below", :yellow)
        Severity: Minor
        Found in lib/spontaneous/cli.rb - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                      elsif t == '"'
                        # Special case: single-character " token
                        if prev_token_last_char =~ /\S/
                          t = CLOSE_DBL_QUOTE
                        else
        Severity: Major
        Found in lib/spontaneous/utils/smart_quotes.rb - About 45 mins to fix

          Method reload! has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 reload! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def reload!
                  rotation do |file, mtime|
                    # Retrive the last modified time
                    new_file = mtimes[file].nil?
                    previous_mtime = mtimes[file] ||= mtime
          Severity: Minor
          Found in lib/spontaneous/loader.rb - About 45 mins 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