qiu8310/text-free

View on GitHub

Showing 17 of 17 total issues

Function exports has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt, serverDirs) {

  if (!grunt.task.exists('textFree')) {
    throw new Error('Gruntfile no textFree task');
  }
Severity: Major
Found in scripts/middle-ware.js - About 5 hrs to fix

    Function goTo has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    Tag.prototype.goTo = function(toIndex, expect, rAllowed) {
      var content = this.ctrl.content;
      if (toIndex >= this.startIndex && toIndex < this.endIndex) {
        return null;
      }
    Severity: Minor
    Found in lib/tag-ctrl.js - About 4 hrs 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 documentClickHandler has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var documentClickHandler = function (e) {
        if (e.target.classList.contains(tfInjectClassName)) {
          var tfObj = tf(e.target.innerHTML), width, dom;
          var handler = function (e) {
            if (!e.target.classList.contains(prefix + 'btn')) {
    Severity: Major
    Found in scripts/inject.js - About 2 hrs to fix

      Function set has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        set: function(key, val, force, obj) {
          if (typeof key !== 'string') {
            return false;
          }
      
      
      Severity: Minor
      Found in lib/kv.js - About 2 hrs 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

      File inject.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* global __textFreeOptions */
      
      /**
       * NOTE: 工具程序,不考虑性能
       */
      Severity: Minor
      Found in scripts/inject.js - About 2 hrs to fix

        Function tf has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function tf(html) {
            var data = {origin: html};
        
            // 去除首尾换行
            html = html.trim();
        Severity: Major
        Found in scripts/inject.js - About 2 hrs to fix

          File tag-ctrl.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          var KV = require('./kv.js');
          var CONST = require('./variable.js');
          var util = require('util');
          
          function Tag(ctrl, raw, key, index) {
          Severity: Minor
          Found in lib/tag-ctrl.js - About 2 hrs to fix

            Function goTo has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Tag.prototype.goTo = function(toIndex, expect, rAllowed) {
              var content = this.ctrl.content;
              if (toIndex >= this.startIndex && toIndex < this.endIndex) {
                return null;
              }
            Severity: Minor
            Found in lib/tag-ctrl.js - About 1 hr to fix

              Function handler has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    var handler = function (e) {
                      if (!e.target.classList.contains(prefix + 'btn')) {
                        return false;
                      }
                      query('.control', dom).removeEventListener('click', handler, false);
              Severity: Minor
              Found in scripts/inject.js - About 1 hr to fix

                Function exec has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                TagCtrl.prototype.exec = function(data, options) {
                  var self = this;
                  data = data || {};
                  options = options || {};
                
                
                Severity: Minor
                Found in lib/tag-ctrl.js - About 1 hr to fix

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

                  function runGruntTask(grunt, task, taskTarget, fn, cb) {
                    if (typeof taskTarget === 'function') {
                      cb = fn;
                      fn = taskTarget;
                      taskTarget = null;
                  Severity: Minor
                  Found in lib/utils.js - About 1 hr to fix

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

                      set: function(key, val, force, obj) {
                        if (typeof key !== 'string') {
                          return false;
                        }
                    
                    
                    Severity: Minor
                    Found in lib/kv.js - About 1 hr to fix

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

                      function getNewestFile(grunt, file) {
                        var dir = path.dirname(file),
                          base = path.basename(file);
                      
                        // 找到一个最新的文件 file
                      Severity: Minor
                      Found in lib/rw.js - About 1 hr to fix

                        Function get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          get: function(key, defaultVal, obj) {
                            if (arguments.length === 2) {
                              obj = defaultVal;
                              defaultVal = undefined;
                            }
                        Severity: Minor
                        Found in lib/kv.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

                        Avoid deeply nested control flow statements.
                        Open

                                        if (data.status === 0) {
                                          dom.parentNode.removeChild(dom);
                                        } else {
                                          window.alert(data.msg);
                                          e.target.classList.remove(prefix + 'disabled');
                        Severity: Major
                        Found in scripts/inject.js - About 45 mins to fix

                          Function runGruntTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function runGruntTask(grunt, task, taskTarget, fn, cb) {
                          Severity: Minor
                          Found in lib/utils.js - About 35 mins to fix

                            Function runGruntTask has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function runGruntTask(grunt, task, taskTarget, fn, cb) {
                              if (typeof taskTarget === 'function') {
                                cb = fn;
                                fn = taskTarget;
                                taskTarget = null;
                            Severity: Minor
                            Found in lib/utils.js - 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

                            Severity
                            Category
                            Status
                            Source
                            Language