jacometoss/PyEWS

View on GitHub
site/search/lunr.js

Summary

Maintainability
F
2 wks
Test Coverage

File lunr.js has 1815 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9
 * Copyright (C) 2020 Oliver Nightingale
 * @license MIT
 */
Severity: Major
Found in site/search/lunr.js - About 4 days to fix

    Function stemmer has 168 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    lunr.stemmer = (function(){
      var step2list = {
          "ational" : "ate",
          "tional" : "tion",
          "enci" : "ence",
    Severity: Major
    Found in site/search/lunr.js - About 6 hrs to fix

      Function query has 132 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      lunr.Index.prototype.query = function (fn) {
        // for each query clause
        // * process terms
        // * expand terms from token set
        // * find matching documents and metadata
      Severity: Major
      Found in site/search/lunr.js - About 5 hrs to fix

        Function porterStemmer has 103 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var porterStemmer = function porterStemmer(w) {
            var stem,
              suffix,
              firstch,
              re,
        Severity: Major
        Found in site/search/lunr.js - About 4 hrs to fix

          Function fromFuzzyString has 90 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
            var root = new lunr.TokenSet
          
            var stack = [{
              node: root,
          Severity: Major
          Found in site/search/lunr.js - About 3 hrs to fix

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

            lunr.Builder.prototype.add = function (doc, attributes) {
              var docRef = doc[this._ref],
                  fields = Object.keys(this._fields)
            
              this._documents[docRef] = attributes || {}
            Severity: Minor
            Found in site/search/lunr.js - About 1 hr to fix

              Function intersect has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              lunr.TokenSet.prototype.intersect = function (b) {
                var output = new lunr.TokenSet,
                    frame = undefined
              
                var stack = [{
              Severity: Minor
              Found in site/search/lunr.js - About 1 hr to fix

                Function lexText has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                lunr.QueryLexer.lexText = function (lexer) {
                  while (true) {
                    var char = lexer.next()
                
                    if (char == lunr.QueryLexer.EOS) {
                Severity: Minor
                Found in site/search/lunr.js - About 1 hr to fix

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

                  lunr.Builder.prototype.createFieldVectors = function () {
                    var fieldVectors = {},
                        fieldRefs = Object.keys(this.fieldTermFrequencies),
                        fieldRefsLength = fieldRefs.length,
                        termIdfCache = Object.create(null)
                  Severity: Minor
                  Found in site/search/lunr.js - About 1 hr to fix

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

                    lunr.tokenizer = function (obj, metadata) {
                      if (obj == null || obj == undefined) {
                        return []
                      }
                    
                    
                    Severity: Minor
                    Found in site/search/lunr.js - About 1 hr to fix

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

                      lunr.QueryParser.parseEditDistance = function (parser) {
                        var lexeme = parser.consumeLexeme()
                      
                        if (lexeme == undefined) {
                          return
                      Severity: Minor
                      Found in site/search/lunr.js - About 1 hr to fix

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

                        lunr.QueryParser.parseBoost = function (parser) {
                          var lexeme = parser.consumeLexeme()
                        
                          if (lexeme == undefined) {
                            return
                        Severity: Minor
                        Found in site/search/lunr.js - About 1 hr to fix

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

                          lunr.Vector.prototype.positionForIndex = function (index) {
                            // For an empty vector the tuple can be inserted at the beginning
                            if (this.elements.length == 0) {
                              return 0
                            }
                          Severity: Minor
                          Found in site/search/lunr.js - About 1 hr to fix

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

                            lunr.QueryParser.parseTerm = function (parser) {
                              var lexeme = parser.consumeLexeme()
                            
                              if (lexeme == undefined) {
                                return
                            Severity: Minor
                            Found in site/search/lunr.js - About 1 hr to fix

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

                              lunr.Index.load = function (serializedIndex) {
                                var attrs = {},
                                    fieldVectors = {},
                                    serializedVectors = serializedIndex.fieldVectors,
                                    invertedIndex = Object.create(null),
                              Severity: Minor
                              Found in site/search/lunr.js - About 1 hr to fix

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

                                lunr.QueryParser.parsePresence = function (parser) {
                                  var lexeme = parser.consumeLexeme()
                                
                                  if (lexeme == undefined) {
                                    return
                                Severity: Minor
                                Found in site/search/lunr.js - About 1 hr to fix

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

                                  lunr.TokenSet.Builder.prototype.insert = function (word) {
                                    var node,
                                        commonPrefix = 0
                                  
                                    if (word < this.previousWord) {
                                  Severity: Minor
                                  Found in site/search/lunr.js - About 1 hr to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                              if (clause.presence == lunr.Query.presence.REQUIRED) {
                                                clauseMatches = clauseMatches.union(matchingDocumentsSet)
                                    
                                                if (requiredMatches[field] === undefined) {
                                                  requiredMatches[field] = lunr.Set.complete
                                    Severity: Major
                                    Found in site/search/lunr.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                if (nEdge in frame.output.edges) {
                                                  // an edge already exists for this character
                                                  // no need to create a new node, just set the finality
                                                  // bit unless this node is already final
                                                  next = frame.output.edges[nEdge]
                                      Severity: Major
                                      Found in site/search/lunr.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                  if (termFieldCache[termField]) {
                                                    continue
                                                  }
                                        Severity: Major
                                        Found in site/search/lunr.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                    if (clause.presence == lunr.Query.presence.PROHIBITED) {
                                                      if (prohibitedMatches[field] === undefined) {
                                                        prohibitedMatches[field] = lunr.Set.empty
                                                      }
                                          
                                          
                                          Severity: Major
                                          Found in site/search/lunr.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                      for (var l = 0; l < matchingDocumentRefs.length; l++) {
                                                        /*
                                                         * All metadata for this term/field/document triple
                                                         * are then extracted and collected into an instance
                                                         * of lunr.MatchData ready to be returned in the query
                                            Severity: Major
                                            Found in site/search/lunr.js - About 45 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                    return lunr.QueryParser.parsePresence
                                              Severity: Major
                                              Found in site/search/lunr.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                      return lunr.QueryParser.parsePresence
                                                Severity: Major
                                                Found in site/search/lunr.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                        return lunr.QueryParser.parsePresence
                                                  Severity: Major
                                                  Found in site/search/lunr.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          return lunr.QueryLexer.lexText
                                                    Severity: Major
                                                    Found in site/search/lunr.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                            return lunr.QueryLexer.lexText
                                                      Severity: Major
                                                      Found in site/search/lunr.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              return lunr.QueryLexer.lexTerm
                                                        Severity: Major
                                                        Found in site/search/lunr.js - About 30 mins to fix

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

                                                          lunr.QueryParser.parseEditDistance = function (parser) {
                                                            var lexeme = parser.consumeLexeme()
                                                          
                                                            if (lexeme == undefined) {
                                                              return
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 1 day to fix
                                                          site/search/lunr.js on lines 3405..3446

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

                                                          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

                                                          lunr.QueryParser.parseBoost = function (parser) {
                                                            var lexeme = parser.consumeLexeme()
                                                          
                                                            if (lexeme == undefined) {
                                                              return
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 1 day to fix
                                                          site/search/lunr.js on lines 3362..3403

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

                                                          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 (re.test(w)) {
                                                                var fp = re.exec(w);
                                                                stem = fp[1];
                                                                suffix = fp[2];
                                                                re = re_mgr0;
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 2 hrs to fix
                                                          site/search/lunr.js on lines 1088..1096

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

                                                          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 (re.test(w)) {
                                                                var fp = re.exec(w);
                                                                stem = fp[1];
                                                                suffix = fp[2];
                                                                re = re_mgr0;
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 2 hrs to fix
                                                          site/search/lunr.js on lines 1076..1084

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

                                                          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 (charB in frame.node.edges) {
                                                                  transposeNode = frame.node.edges[charB]
                                                                } else {
                                                                  transposeNode = new lunr.TokenSet
                                                                  frame.node.edges[charB] = transposeNode
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 2 hrs to fix
                                                          site/search/lunr.js on lines 1454..1459

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

                                                          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 (char in frame.node.edges) {
                                                                  noEditNode = frame.node.edges[char]
                                                                } else {
                                                                  noEditNode = new lunr.TokenSet
                                                                  frame.node.edges[char] = noEditNode
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 2 hrs to fix
                                                          site/search/lunr.js on lines 1541..1546

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

                                                          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

                                                          lunr.QueryLexer.lexEditDistance = function (lexer) {
                                                            lexer.ignore()
                                                            lexer.acceptDigitRun()
                                                            lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)
                                                            return lunr.QueryLexer.lexText
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 1 hr to fix
                                                          site/search/lunr.js on lines 3110..3115

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

                                                          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

                                                          lunr.QueryLexer.lexBoost = function (lexer) {
                                                            lexer.ignore()
                                                            lexer.acceptDigitRun()
                                                            lexer.emit(lunr.QueryLexer.BOOST)
                                                            return lunr.QueryLexer.lexText
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 1 hr to fix
                                                          site/search/lunr.js on lines 3103..3108

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

                                                          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 (char == "^") {
                                                                lexer.backup()
                                                                if (lexer.width() > 0) {
                                                                  lexer.emit(lunr.QueryLexer.TERM)
                                                                }
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 1 hr to fix
                                                          site/search/lunr.js on lines 3154..3160

                                                          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

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

                                                              if (char == "~") {
                                                                lexer.backup()
                                                                if (lexer.width() > 0) {
                                                                  lexer.emit(lunr.QueryLexer.TERM)
                                                                }
                                                          Severity: Major
                                                          Found in site/search/lunr.js and 1 other location - About 1 hr to fix
                                                          site/search/lunr.js on lines 3162..3168

                                                          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

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status