digitalheir/bibliography-js

View on GitHub

Showing 101 of 101 total issues

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

    {"name": "braced_string", "symbols": [brace_l, "braced_string$ebnf$1", brace_r], "postprocess":  function (data, location, reject) {
          var tkz = [];
          for(var i in data[1]) tkz.push(data[1][i][0]);
          return {type:'braced', data:tkz};
        }
Severity: Major
Found in depr/bibtex/parser/parser.js and 1 other location - About 2 hrs to fix
depr/bibtex/parser/parser.js on lines 166..171

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

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

  static isNum(c) {
    return c == '0' ||
      c == '1' ||
      c == '2' ||
      c == '3' ||
Severity: Major
Found in depr/bibtex/lexer/lexer.js and 1 other location - About 2 hrs to fix
depr/bibtex/lexer/lexer.js on lines 104..115

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

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

  static resolveStringDeclarations(referenceStack, wrapper, compiledSoFar, rawStrings) {
    if (wrapper.type == 'quotedstringwrapper') {
      return new StringValue({
        type: wrapper.type,
        data: wrapper.data.map((strObj) => {
Severity: Minor
Found in depr/bibtex/field_value/StringValue.js - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function computeUnicodeString has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

export const articleToHtml = (item: BibliographyItem) => {
  const parts: string[] = [];

  pushNames(item, parts);
  pushTitle(item, parts);
Severity: Major
Found in src/reference/AMA/html/html.ts and 1 other location - About 2 hrs to fix
src/reference/AMA/html/book.ts on lines 8..19

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

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

export const bookToHtml = (item: BibliographyItem) => {
  const parts: string[] = [];

  pushNames(item, parts);
  pushTitle(item, parts);
Severity: Major
Found in src/reference/AMA/html/book.ts and 1 other location - About 2 hrs to fix
src/reference/AMA/html/html.ts on lines 42..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 76.

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

  renderAuthors(obj) {
    const children = [];

    if (!obj.fields.author) throw new Error("Entry with id " + obj.id + " did not have author set.");
    const authors = obj.fields.author.getAuthors();
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

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

const acuteAccent = modifyStringFunction({
  e: 'é',
  y: 'ý',
  u: 'ú',
  i: 'í',
Severity: Major
Found in depr/bibtex/field_value/specialCharsHandlers.js and 1 other location - About 1 hr to fix
depr/bibtex/field_value/specialCharsHandlers.js on lines 64..78

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

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

const dieresis = modifyStringFunction({
  e: 'ë',
  y: 'ÿ',
  u: 'ü',
  i: 'ï',
Severity: Major
Found in depr/bibtex/field_value/specialCharsHandlers.js and 1 other location - About 1 hr to fix
depr/bibtex/field_value/specialCharsHandlers.js on lines 35..49

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

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

const specialChars = {
  'i': 'ı',
  'j': 'ȷ',
  'oe': 'œ',
  'OE': 'Œ',
Severity: Major
Found in depr/bibtex/field_value/specialCharsHandlers.js and 1 other location - About 1 hr to fix
depr/bibtex/field_value/StringValue.js on lines 154..168

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

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

    const purifyEscapeExceptions = {
      'i': 'i',
      'j': 'j',
      'oe': 'oe',
      'OE': 'OE',
Severity: Major
Found in depr/bibtex/field_value/StringValue.js and 1 other location - About 1 hr to fix
depr/bibtex/field_value/specialCharsHandlers.js on lines 142..156

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

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

  readNextToken() {
    if (this.pos >= this.str.length) return null;

    let c = this.str.charAt(this.pos);
    if (Lexer.isWhiteSpace(c)) return this.getWhiteSpace(c);
Severity: Minor
Found in depr/bibtex/lexer/lexer.js - About 1 hr to fix

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

    function intersperse(arr, sep) {
      if (arr.length === 0) return [];
      return arr.slice(1).reduce((xs, x) => xs.concat([sep, x]), [arr[0]]);
    }
    Severity: Major
    Found in src2/internal/reference/MLA/Parenthetical.js and 1 other location - About 1 hr to fix
    src2/internal/reference/AMA/Reference.js on lines 17..20

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

    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 flatten has a Cognitive Complexity of 14 (exceeds 5 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

    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

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

    function intersperse(arr, sep) {
      if (arr.length === 0) return [];
      return arr.slice(1).reduce((xs, x) => xs.concat([sep, x]), [arr[0]]);
    }
    Severity: Major
    Found in src2/internal/reference/AMA/Reference.js and 1 other location - About 1 hr to fix
    src2/internal/reference/MLA/Parenthetical.js on lines 22..25

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

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

    function stringifyLaTeXInner(tex: LaTeX | TeXArg, soFar: string[]): void {
      if (isTeXComm(tex)) {
        soFar.push("\\", tex.name);
        tex.arguments.forEach(l => stringifyLaTeXInner(l, soFar));
      }
    Severity: Minor
    Found in src/util.ts - 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 a Cognitive Complexity of 13 (exceeds 5 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

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

    function stringifyLaTeXInner(tex: LaTeX | TeXArg, soFar: string[]): void {
      if (isTeXComm(tex)) {
        soFar.push("\\", tex.name);
        tex.arguments.forEach(l => stringifyLaTeXInner(l, soFar));
      }
    Severity: Minor
    Found in src/util.ts - About 1 hr to fix

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

      const graveAccent = modifyStringFunction({
        e: 'è',
        u: 'ù',
        i: 'ì',
        o: 'ò',
      Severity: Major
      Found in depr/bibtex/field_value/specialCharsHandlers.js and 1 other location - About 1 hr to fix
      depr/bibtex/field_value/specialCharsHandlers.js on lines 50..62

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

      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

      const circumflex = modifyStringFunction({
        e: 'ê',
        u: 'û',
        i: 'î',
        o: 'ô',
      Severity: Major
      Found in depr/bibtex/field_value/specialCharsHandlers.js and 1 other location - About 1 hr to fix
      depr/bibtex/field_value/specialCharsHandlers.js on lines 22..33

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

      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

      Severity
      Category
      Status
      Source
      Language