200ok-ch/organice

View on GitHub
src/lib/org_utils.js

Summary

Maintainability
D
2 days
Test Coverage

Function pathAndPartOfListItemWithIdInAttributedString has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const pathAndPartOfListItemWithIdInAttributedString = (parts, listItemId) =>
  parts
    .map((part, partIndex) => {
      if (part.get('type') === 'list') {
        return part
Severity: Minor
Found in src/lib/org_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 pathAndPartOfTableContainingCellIdInAttributedString has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export const pathAndPartOfTableContainingCellIdInAttributedString = (parts, cellId) =>
  parts
    .map((part, partIndex) => {
      if (part.get('type') === 'table') {
        if (tablePartContainsCellId(part, cellId)) {
Severity: Minor
Found in src/lib/org_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 pathAndPartOfListContainingItemIdInAttributedString has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export const pathAndPartOfListContainingItemIdInAttributedString = (parts, itemId) =>
  parts
    .map((part, partIndex) => {
      if (part.get('type') === 'list') {
        if (listPartContainsItemId(part, itemId)) {
Severity: Minor
Found in src/lib/org_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 pathAndPartOfTimestampItemWithIdInAttributedString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const pathAndPartOfTimestampItemWithIdInAttributedString = (parts, timestampId) =>
  parts
    .map((part, partIndex) => {
      if (part.get('type') === 'timestamp' && part.get('id') === timestampId) {
        return {
Severity: Minor
Found in src/lib/org_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 getOpenHeaderPaths has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const getOpenHeaderPaths = (headers) => {
  let openedHeaders = [];
  for (let i = 0; i < headers.size; ++i) {
    const header = headers.get(i);
    if (!header.get('opened')) {
Severity: Minor
Found in src/lib/org_utils.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

      return null;
Severity: Major
Found in src/lib/org_utils.js - About 30 mins to fix

    Unexpected console statement.
    Open

          console.warn('crypto.subtle module is not available, returning an empty bogus hash.');
    Severity: Minor
    Found in src/lib/org_utils.js by eslint

    disallow the use of console (no-console)

    In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

    console.log("Made it here.");
    console.error("That shouldn't have happened.");

    Rule Details

    This rule disallows calls to methods of the console object.

    Examples of incorrect code for this rule:

    /*eslint no-console: "error"*/
    
    console.log("Log a debug level message.");
    console.warn("Log a warn level message.");
    console.error("Log an error level message.");

    Examples of correct code for this rule:

    /*eslint no-console: "error"*/
    
    // custom console
    Console.log("Hello world!");

    Options

    This rule has an object option for exceptions:

    • "allow" has an array of strings which are allowed methods of the console object

    Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

    /*eslint no-console: ["error", { allow: ["warn", "error"] }] */
    
    console.warn("Log a warn level message.");
    console.error("Log an error level message.");

    When Not To Use It

    If you're using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

    Related Rules

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

    export const pathAndPartOfListItemWithIdInHeaders = (headers, listItemId) =>
      headers
        .map((header, headerIndex) => {
          const pathAndPart = pathAndPartOfListItemWithIdInAttributedString(
            header.get('description'),
    Severity: Major
    Found in src/lib/org_utils.js and 1 other location - About 4 hrs to fix
    src/lib/org_utils.js on lines 605..623

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

    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 pathAndPartOfTableContainingCellIdInHeaders = (headers, cellId) =>
      headers
        .map((header, headerIndex) => {
          const pathAndPart = pathAndPartOfTableContainingCellIdInAttributedString(
            header.get('description'),
    Severity: Major
    Found in src/lib/org_utils.js and 1 other location - About 4 hrs to fix
    src/lib/org_utils.js on lines 585..603

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

    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 (pathAndPart) {
                  const { path, timestampPart } = pathAndPart;
                  return {
                    path: [partIndex, 'items', itemIndex, 'contents'].concat(path),
                    timestampPart,
    Severity: Major
    Found in src/lib/org_utils.js and 1 other location - About 2 hrs to fix
    src/lib/org_utils.js on lines 408..427

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

    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 (item.get('id') === listItemId) {
                  return {
                    path: [partIndex, 'items', itemIndex],
                    listItemPart: item,
                  };
    Severity: Major
    Found in src/lib/org_utils.js and 1 other location - About 2 hrs to fix
    src/lib/org_utils.js on lines 328..348

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

    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 rowIndexContainingCellId = tablePart
        .get('contents')
        .findIndex((row) => row.get('contents').some((cell) => cell.get('id') === cellId));
    Severity: Minor
    Found in src/lib/org_utils.js and 1 other location - About 55 mins to fix
    src/lib/org_utils.js on lines 292..294

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

    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

      tablePart
        .get('contents')
        .some((row) => row.get('contents').some((cell) => cell.get('id') === cellId));
    Severity: Minor
    Found in src/lib/org_utils.js and 1 other location - About 55 mins to fix
    src/lib/org_utils.js on lines 628..630

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

    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