digitalheir/bibliography-js

View on GitHub

Showing 49 of 101 total issues

Function vonLastFirst has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function vonLastFirst(authorTokens) {
  let commaPos = -1;
  for (let i = 0; i < authorTokens.length; i++)
    if (authorTokens[i].type == ',') {
      commaPos = i;
Severity: Minor
Found in depr/bibtex/field_value/AuthorValue.js - 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 flatten has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function flatten(obj) {
  if (typeof obj === 'object' &&
    (obj.type == 'quotedstring' ||
    obj.type == 'quotedstringwrapper' ||
    obj.type == 'bracedstringwrapper')
Severity: Minor
Found in depr/bibtex/field_value/StringValue.js - About 1 hr to fix

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

      render() {
        const obj = this.props.entry;
        const isEntry = (obj instanceof Entry);
        if (!isEntry) throw new Error("Object must be of type Entry: " + JSON.stringify(obj));
    
    
    Severity: Minor
    Found in src2/internal/reference/AMA/Reference.js - About 1 hr to fix

      Function joinTokens has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function joinTokens(arr){
          var strs = [];
          for(var i=0;i<arr.length;i++){
            if(typeof arr[i] == 'object'){
              if(!arr[i].string) throw new Error("Expected token to have a string field called 'string' in object "+JSON.stringify(arr[i]));
      Severity: Minor
      Found in depr/bibtex/parser/parser.js - About 45 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

      Function firstVonLast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function firstVonLast(authorTokens) {
        let vonStartInclusive = -1;
        let vonEndExclusive = -1;
        let firstNameEndExclusive = -1;
        for (let i = 0; i < authorTokens.length - 1; i++) {// -1 because last word must be lastName
      Severity: Minor
      Found in depr/bibtex/field_value/AuthorValue.js - About 45 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

      Consider simplifying this complex logical expression.
      Open

              if (wordSegment.type == 'braced'
                && wordSegment.data[0]
                && wordSegment.data[0].constructor == Array
                && wordSegment.data[0].length == 1
                && typeof wordSegment.data[0][0] == 'string'
      Severity: Major
      Found in depr/bibtex/field_value/StringValue.js - About 40 mins to fix

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

          static joinSimpleString(data) {
            if (typeof data === 'string') return data;
            else if (data.constructor == Array) {
              const str = [];
              for (let i = 0; i < data.length; i++) {
        Severity: Minor
        Found in depr/bibtex/field_value/StringValue.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

        Avoid too many return statements within this function.
        Open

              if (Number.isFinite(number)) return number;
        Severity: Major
        Found in depr/bibtex/lexer/lexer.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            else if (wordObj.unicode)  return getFirstLetter(wordObj.unicode);
          Severity: Major
          Found in depr/bibtex/field_value/utils.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  else return new Token(NUMBER, numString);
            Severity: Major
            Found in depr/bibtex/lexer/lexer.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  else if (typeof data.data == 'string') return data.string;
              Severity: Major
              Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    else if (typeof obj === 'object' && obj.type == 'quotedstring') return StringValue.computeUnicodeString(braceDepth, obj.data);
                Severity: Major
                Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return new Token(ID, chars.join("").trim());
                  Severity: Major
                  Found in depr/bibtex/lexer/lexer.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      else if (authorToken.constructor == Array) return authorToken.map(flattenToString).join('');
                    Severity: Major
                    Found in depr/bibtex/field_value/utils.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        else if (typeof obj === 'string') return obj;
                      Severity: Major
                      Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return StringValue.computeUnicodeString(braceDepth, obj.data.map(o => {
                                if (!o) throw new Error("Expected non-null elements in " + JSON.stringify(o));
                                //console.log("braced", obj.data);
                                return StringValue.computeUnicodeString(braceDepth + 1, o)
                              }));
                        Severity: Major
                        Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              else if (typeof obj === 'object' && obj.unicode) return obj.unicode;
                          Severity: Major
                          Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                else if (obj.constructor === Number) return obj + "";
                            Severity: Major
                            Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    if (specialChar) return specialChar(specialChar);
                              Severity: Major
                              Found in depr/bibtex/field_value/StringValue.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                  else if (wordObj.constructor == Array) return getFirstLetter(flattenToString(wordObj).trim());
                                Severity: Major
                                Found in depr/bibtex/field_value/utils.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language