digitalheir/bibliography-js

View on GitHub

Showing 101 of 101 total issues

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

  for (let i = 0; i < commaPos; i++)
    if (startsWithLowerCase(authorTokens[i])) {
      if (vonStartInclusive < 0) vonStartInclusive = i;
      vonEndExclusive = i + 1;
    }
Severity: Major
Found in depr/bibtex/field_value/AuthorValue.js and 1 other location - About 1 hr to fix
depr/bibtex/field_value/AuthorValue.js on lines 57..61

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

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

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

export const pushJournalDetails = (item: BibliographyItem, parts: string[]) => {
  const journal = renderJournalDetailsToHtml(item);
  if (!!journal) parts.push(journal);
};
Severity: Major
Found in src/reference/MLA/html/journal.ts and 1 other location - About 1 hr to fix
src/reference/AMA/html/journal.ts on lines 66..69

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

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

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

export const pushJournalDetails = (item: BibliographyItem, parts: string[]) => {
  const journal = renderJournalDetailsToHtml(item);
  if (!!journal) parts.push(journal);
};
Severity: Major
Found in src/reference/AMA/html/journal.ts and 1 other location - About 1 hr to fix
src/reference/MLA/html/journal.ts on lines 67..70

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

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

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

  for (let i = 0; i < commaPos; i++)
    if (startsWithLowerCase(authorTokens[i])) {
      if (vonStartInclusive < 0) vonStartInclusive = i;
      vonEndExclusive = i + 1;
    }
Severity: Major
Found in depr/bibtex/field_value/AuthorValue.js and 1 other location - About 1 hr to fix
depr/bibtex/field_value/AuthorValue.js on lines 99..103

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

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 getFirstLetter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const getFirstLetter = function (wordObj) {
  if (typeof wordObj === 'string') {
    if (wordObj.length > 1 && wordObj.charAt(0) == '/') return wordObj.charAt(1);
    else if (wordObj.length > 0) return wordObj.charAt(0);
    else return null;
Severity: Minor
Found in depr/bibtex/field_value/utils.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 vonLastJrFirst has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function vonLastJrFirst(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

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

    function processSpecialChars(words) {
      return words.map(word=> {
        if (word.constructor == Array) {
          return word.map(wordSegment => {
            if (wordSegment.type == 'braced'
    Severity: Minor
    Found in depr/bibtex/field_value/StringValue.js - About 1 hr to fix

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

        static computeUnicodeString(braceDepth, obj) {
          //console.log(braceDepth, JSON.stringify(obj));
          if (typeof obj === 'string') return obj;
          else if (obj.constructor == Array) return obj.map(o => {
            if (!o) throw new Error("Expected non-null elements in " + JSON.stringify(o));
      Severity: Minor
      Found in depr/bibtex/field_value/StringValue.js - About 1 hr to fix

        Function render has a Cognitive Complexity of 10 (exceeds 5 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/MLA/Parenthetical.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 concatStrings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function concatStrings(array) {
          const words = [];
          for (let i = 0; i < array.length; i++) {
            const obj = array[i];
            if (obj == ',') words.push({type: ','});
        Severity: Minor
        Found in depr/bibtex/field_value/StringValue.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 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

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

                    for(var Ti = 0;Ti<data[0].length;Ti++) tokens.push(data[0][Ti][0]);
            Severity: Major
            Found in depr/bibtex/parser/parser.js and 2 other locations - About 50 mins to fix
            depr/bibtex/parser/parser.js on lines 87..88
            depr/bibtex/parser/parser.js on lines 202..202

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

            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

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

              for (let i = 0; i < authorTokens.length; i++)
                if (authorTokens[i].type == ',') {
                  commaPos = i;
                  break;
                }
            Severity: Minor
            Found in depr/bibtex/field_value/AuthorValue.js and 1 other location - About 50 mins to fix
            depr/bibtex/field_value/AuthorValue.js on lines 49..53

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

            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

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

              for (let i = 0; i < authorTokens.length; i++)
                if (authorTokens[i].type == ',') {
                  commaPos = i;
                  break;
                }
            Severity: Minor
            Found in depr/bibtex/field_value/AuthorValue.js and 1 other location - About 50 mins to fix
            depr/bibtex/field_value/AuthorValue.js on lines 85..89

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

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

                      for(var tk=0; tk < data[0].length; tk++)
                        toeknz.push(data[0][tk][0]);
            Severity: Major
            Found in depr/bibtex/parser/parser.js and 2 other locations - About 50 mins to fix
            depr/bibtex/parser/parser.js on lines 202..202
            depr/bibtex/parser/parser.js on lines 289..289

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

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

                         for(var i=0;i<match[1].length;i++) tokenz.push(match[1][i][3]);
            Severity: Major
            Found in depr/bibtex/parser/parser.js and 2 other locations - About 50 mins to fix
            depr/bibtex/parser/parser.js on lines 87..88
            depr/bibtex/parser/parser.js on lines 289..289

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

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

            Severity
            Category
            Status
            Source
            Language