puffer/puffer_pages

View on GitHub

Showing 219 of 219 total issues

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

        if (posLess(m.to, p.to)) newParts.push({from: m.to, to: p.to});
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror.js on lines 3528..3528

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

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

      updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]), hlSpans(lines[0]));
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror.js on lines 2009..2009

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

              (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror.js on lines 2175..2175

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

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

        updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]), hlSpans(lines[0]));
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror.js on lines 2018..2018

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

      if (/^script$/i.test(state.htmlState.context.tagName)) {
        state.token = javascript;
        state.localState = jsMode.startState(htmlMode.indent(state.htmlState, ""));
      }
      else if (/^style$/i.test(state.htmlState.context.tagName)) {
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror/htmlmixed.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror/htmlmixed.js on lines 13..16

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

          if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror.js on lines 2176..2176

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

        if (posLess(p.from, m.from)) newParts.push({from: p.from, to: m.from});
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 35 mins to fix
app/assets/javascripts/puffer/codemirror.js on lines 3529..3529

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

Method translatable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def translatable *fields
            if PufferPages.localize
              translates *fields, fallbacks_for_empty_translations: true
              translation_class.send(:include, ActiveUUID::UUID)

Severity: Minor
Found in lib/puffer_pages/backends/models/mixins/translatable.rb - About 35 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 failure_message_for_should has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def failure_message_for_should
          message = ''
          message << "expected action to render #{page_message}\n"
          message << "with drops #{drops_message}\n" if with_drops?
          if with_drops? && !drops_conformity
Severity: Minor
Found in lib/puffer_pages/rspec/matchers/render_page.rb - About 35 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 too many return statements within this function.
Open

            return null;
Severity: Major
Found in app/assets/javascripts/puffer/codemirror/yaml.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return ret("operator", null, stream.current());
    Severity: Major
    Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return ret("property", "variable");
      Severity: Major
      Found in app/assets/javascripts/puffer/codemirror/css.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return chain(stream, state, jsTokenComment);
        Severity: Major
        Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
                                                   block, poplex, poplex);
          Severity: Major
          Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return 'meta';
            Severity: Major
            Found in app/assets/javascripts/puffer/codemirror/yaml.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return ret("error", "error");
              Severity: Major
              Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return null;
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror/xml.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
                                                        poplex, statement, poplex);
                  Severity: Major
                  Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        if (type == "case") return cont(expression, expect(":"));
                    Severity: Major
                    Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return pass(pushlex("stat"), expression, expect(";"), poplex);
                      Severity: Major
                      Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language