Noosfero/noosfero

View on GitHub
plugins/display_content/public/javascripts/jstree-v.pre1.0/_docs/syntax/!script.js

Summary

Maintainability
F
3 wks
Test Coverage

Function SyntaxHighlighter has a Cognitive Complexity of 380 (exceeds 5 allowed). Consider refactoring.
Open

if (!window.SyntaxHighlighter) var SyntaxHighlighter = function() { 

// Shortcut object which will be assigned to the SyntaxHighlighter variable.
// This is a shorthand for local reference in order to avoid long namespace 
// references to SyntaxHighlighter.whatever...

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

if (!window.SyntaxHighlighter) var SyntaxHighlighter = function() { 

// Shortcut object which will be assigned to the SyntaxHighlighter variable.
// This is a shorthand for local reference in order to avoid long namespace 
// references to SyntaxHighlighter.whatever...

    File !script.js has 1320 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * SyntaxHighlighter
     * http://alexgorbatchev.com/
     *
     * SyntaxHighlighter is donationware. If you are using it, please donate.

      Function matchRecursive has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
      Open

      XRegExp.matchRecursive = function (str, left, right, flags, options) {
          var options      = options || {},
              escapeChar   = options.escapeChar,
              vN           = options.valueNames,
              flags        = flags || "",

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

                  copyToClipboard : function(highlighter)
                  {
                      var flashDiv, flashSwf,
                          highlighterId = highlighter.id
                          ;

        Function matchRecursive has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        XRegExp.matchRecursive = function (str, left, right, flags, options) {
            var options      = options || {},
                escapeChar   = options.escapeChar,
                vN           = options.valueNames,
                flags        = flags || "",

          Function highlight has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              highlight: function(code, params)
              {
                  // using variables for shortcuts because JS compressor will shorten local variable names
                  var conf = sh.config,
                      vars = sh.vars,

            Function highlight has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                highlight : function(globalParams, element)
                {
                    function toArray(source)
                    {
                        var result = [];

              Function create has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                              this.create = function()
                              {
                                  var config = sh.config;
                                  
                                  // disable functionality if running locally

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

                sh.HtmlScript = function(scriptBrushName)
                {
                    var brushClass = sh.utils.findBrush(scriptBrushName),
                        scriptBrush,
                        xmlBrush = new sh.brushes.Xml(),

                  Function createDisplayLines has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      createDisplayLines : function(code)
                      {
                          var lines = code.split(/\n/g),
                              firstLine = parseInt(this.getParam('first-line')),
                              padLength = this.getParam('pad-line-numbers'),

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

                            createButton : function(label, highlighterId, commandName)
                            {
                                var a = document.createElement('a'),
                                    style = a.style,
                                    config = sh.config,

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

                              measureSpace : function()
                              {
                                  var container = document.createElement('div'),
                                      span,
                                      result = 0,

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

                        SyntaxHighlighter.brushes.Xml = function()
                        {
                            function process(match, regexInfo)
                            {
                                var constructor = SyntaxHighlighter.Match,

                          Function printSource has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                      printSource : function(highlighter)
                                      {
                                          this.create = function()
                                          {
                                              return sh.config.strings.print;

                            Function process has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function process(match, info)
                                {
                                    var code = match.code,
                                        matches = [],
                                        regexList = scriptBrush.regexList,

                              Function parseParams has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      parseParams: function(str)
                                      {
                                          var match, 
                                              result = {},
                                              arrayRegex = new XRegExp("^\\[(?<values>(.*?))\\]$"),

                                Function processSmartTabs has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        processSmartTabs : function(code, tabSize)
                                        {
                                            var lines = code.split('\n'),
                                                tab = '\t',
                                                spaces = ''

                                  Function decorate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          decorate: function(str, css)
                                          {
                                              if (str == null || str.length == 0 || str == '\n') 
                                                  return str;
                                      

                                    Consider simplifying this complex logical expression.
                                    Open

                                    if (!window.SyntaxHighlighter) var SyntaxHighlighter = function() { 
                                    
                                    // Shortcut object which will be assigned to the SyntaxHighlighter variable.
                                    // This is a shorthand for local reference in order to avoid long namespace 
                                    // references to SyntaxHighlighter.whatever...

                                      Avoid deeply nested control flow statements.
                                      Open

                                                      if (vN) {
                                                          if (vN[0] && outerStart > lastOuterEnd)
                                                                     output.push([vN[0], str.slice(lastOuterEnd, outerStart), lastOuterEnd, outerStart]);
                                                          if (vN[1]) output.push([vN[1], str.slice(outerStart,   innerStart), outerStart,   innerStart]);
                                                          if (vN[2]) output.push([vN[2], str.slice(innerStart,   delimStart), innerStart,   delimStart]);

                                        Avoid deeply nested control flow statements.
                                        Open

                                                    if (match[3])
                                                        hasNamedCapture = true;

                                          Avoid deeply nested control flow statements.
                                          Open

                                                  } else if (match[4]) {
                                                      index = indexOf(captureNames, match[4]);
                                                      // keep backreferences separate from subsequent literal numbers
                                                      // preserve backreferences to named groups that are undefined at this point as literal strings
                                                      output.push(index > -1 ?

                                            Avoid deeply nested control flow statements.
                                            Open

                                                            if (name) match[name] = match[i];

                                              Avoid deeply nested control flow statements.
                                              Open

                                                                  if (arguments[i] === undefined) match[i] = undefined;

                                                Avoid deeply nested control flow statements.
                                                Open

                                                                if (!global)
                                                                    break;

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

                                                          popup: function(url, name, width, height, options)

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

                                                    XRegExp.matchRecursive = function (str, left, right, flags, options) {

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

                                                              executeCommand : function(sender, event, highlighterId, commandName, args)

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

                                                        SyntaxHighlighter.brushes.Xml = function()
                                                        {
                                                            function process(match, regexInfo)
                                                            {
                                                                var constructor = SyntaxHighlighter.Match,

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

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

                                                                              function params(list)
                                                                              {
                                                                                  var result = '';
                                                                                  
                                                                                  for (var name in list)
                                                          plugins/display_content/public/javascripts/jstree-v.pre1.0/_docs/syntax/!script.js on lines 335..343

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

                                                          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

                                                                              function attributes(list)
                                                                              {
                                                                                  var result = '';
                                                                                  
                                                                                  for (var name in list)
                                                          plugins/display_content/public/javascripts/jstree-v.pre1.0/_docs/syntax/!script.js on lines 325..333

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

                                                          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

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status