puffer/puffer_pages

View on GitHub

Showing 219 of 219 total issues

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

      if (scrollPos.scrollLeft != null) {
        setScrollLeft(cm, scrollPos.scrollLeft);
        if (Math.abs(cm.view.scrollLeft - startLeft) > 1) changed = true;
      }
Severity: Major
Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
app/assets/javascripts/puffer/codemirror.js on lines 2239..2242

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

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

Consider simplifying this complex logical expression.
Open

    if (options.resizeFx && RightJS.Fx && prev_panel && (swapping || loading)) {
      controller.__working = true;
      var unlock = function() { controller.__working = false; };

      // calculating the visual effects durations
Severity: Critical
Found in app/assets/javascripts/puffer/right-tabs-src.js - About 1 hr to fix

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

      function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) {
        var history = cm.view.history;
        history.undone.length = 0;
        var time = +new Date, cur = lst(history.done);
        
    Severity: Minor
    Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

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

            token: function(stream, state) {
              if (!state.innerActive) {
                var cutOff = Infinity, oldContent = stream.string;
                for (var i = 0; i < n_others; ++i) {
                  var other = others[i];
        Severity: Minor
        Found in app/assets/javascripts/puffer/multiplex.js - About 1 hr to fix

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

            function highlightWorker(cm) {
              var view = cm.view, doc = view.doc;
              if (view.frontier >= cm.display.showingTo) return;
              var end = +new Date + cm.options.workTime;
              var state = copyState(view.mode, getStateBefore(cm, view.frontier));
          Severity: Minor
          Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

            Method arranged has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def arranged
                arranged = ActiveSupport::OrderedHash.new
                insertion_points = [arranged]
                depth = 0
                each do |node|
            Severity: Minor
            Found in lib/puffer_pages/extensions/core.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    def initialize(tag_name, markup, tokens)
                      if markup =~ Syntax
            
                        @helper_name, @arguments, @attributes = $1, [], {}
            
            
            Severity: Minor
            Found in lib/puffer_pages/liquid/tags/url.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 moveVisually has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function moveVisually(line, start, dir, byUnit) {
                var bidi = getOrder(line);
                if (!bidi) return moveLogically(line, start, dir, byUnit);
                var moveOneUnit = byUnit ? function(pos, dir) {
                  do pos += dir;
            Severity: Minor
            Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

              Function handleKeyBinding has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function handleKeyBinding(cm, e) {
                  // Handle auto keymap transitions
                  var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
                  clearTimeout(maybeTransition);
                  if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
              Severity: Minor
              Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                Function keywords has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var keywords = function(){
                    function kw(type) {return {type: type, style: "keyword"};}
                    var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
                    var operator = kw("operator"), atom = {type: "atom", style: "atom"};
                    
                Severity: Minor
                Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 1 hr to fix

                  Function coordsCharInner has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function coordsCharInner(cm, lineObj, lineNo, x, y) {
                      var innerOff = y - heightAtLine(cm, lineObj);
                      var wrongLine = false, cWidth = cm.display.wrapper.clientWidth;
                      var measurement = measureLine(cm, lineObj);
                  
                  
                  Severity: Minor
                  Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                    Function clear has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      TextMarker.prototype.clear = function() {
                        if (this.explicitlyCleared) return;
                        startOperation(this.cm);
                        var view = this.cm.view, min = null, max = null;
                        for (var i = 0; i < this.lines.length; ++i) {
                    Severity: Minor
                    Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                      Function findPosH has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function findPosH(cm, dir, unit, visually) {
                          var doc = cm.view.doc, end = cm.view.sel.head, line = end.line, ch = end.ch;
                          var lineObj = getLine(doc, line);
                          function findNextLine() {
                            var l = line + dir;
                      Severity: Minor
                      Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                        Function cursorCoords has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          function cursorCoords(cm, pos, context, lineObj, measurement) {
                            lineObj = lineObj || getLine(cm.view.doc, pos.line);
                            if (!measurement) measurement = measureLine(cm, lineObj);
                            function get(ch, right) {
                              var m = measureChar(cm, lineObj, ch, measurement);
                        Severity: Minor
                        Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                            scrollLeft: function() {
                              if (!this.prevButton.hasClass('rui-tabs-scroller-disabled')) {
                                this[this.isCarousel ? 'prev' : 'justScroll'](+0.6);
                              }
                              return this;
                          Severity: Major
                          Found in app/assets/javascripts/puffer/right-tabs-src.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/puffer/right-tabs-src.js on lines 679..684

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

                            scrollRight: function() {
                              if (!this.nextButton.hasClass('rui-tabs-scroller-disabled')) {
                                this[this.isCarousel ? 'next' : 'justScroll'](-0.6);
                              }
                              return this;
                          Severity: Major
                          Found in app/assets/javascripts/puffer/right-tabs-src.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/puffer/right-tabs-src.js on lines 667..672

                          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 highlightLine has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function highlightLine(cm, line, state) {
                              // A styles array always starts with a number identifying the
                              // mode/overlays that it is based on (for easy invalidation).
                              var st = [cm.view.modeGen];
                              // Compute the base array of styles
                          Severity: Minor
                          Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                              function endOperation(cm) {
                                var op = cm.curOp;
                                if (--op.depth) return;
                                cm.curOp = null;
                                var view = cm.view, display = cm.display;
                            Severity: Minor
                            Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                                function indentLine(cm, n, how, aggressive) {
                                  var doc = cm.view.doc;
                                  if (!how) how = "add";
                                  if (how == "smart") {
                                    if (!cm.view.mode.indent) how = "prev";
                              Severity: Minor
                              Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language