KarrLab/datanator_frontend

View on GitHub

Showing 165 of 403 total issues

Avoid deeply nested control flow statements.
Open

            if ("taxon_distance" in rawDatum) {
              formattedDatum[
                "taxonomicProximity"
              ] = DataTable.calcTaxonomicDistance(
                rawDatum.taxon_distance,
Severity: Major
Found in src/scenes/BiochemicalEntityDetails/Gene/ProteinModificationDataTable.js - About 45 mins to fix

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

      updateStateFromLocation() {
        if (this.unlistenToHistory) {
          const route = parseHistoryLocationPathname(this.props.history);
          if (
            route.route === "search" &&
    Severity: Minor
    Found in src/components/SearchForm/SearchForm.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 numericComparator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      static numericComparator(valueA, valueB) {
        if (valueA == null) {
          if (valueB == null) {
            return 0;
          } else {
    Severity: Minor
    Found in src/scenes/BiochemicalEntityDetails/DataTable/DataTable.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 setModel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      setModel(range) {
        if (range == null) {
          this.min = this.loBound;
          this.max = this.hiBound;
        } else {
    Severity: Minor
    Found in src/scenes/BiochemicalEntityDetails/NumberFilter.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 parseHistoryLocationPathname has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function parseHistoryLocationPathname(history) {
      const pathRegex = /^(\/(.*?)(\/(.*?)(\/(.*?))?)?)?\/?$/;
      const match = history.location.pathname.match(pathRegex);
      let route = null;
      let query = null;
    Severity: Minor
    Found in src/utils/utils.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

    Avoid deeply nested control flow statements.
    Open

                if (metConc.reference.namespace === "doi") {
                  conc.source = {
                    id: "DOI: " + metConc.reference.id,
                    url: "https://dx.doi.org/" + metConc.reference.id,
                  };
    Severity: Major
    Found in src/scenes/BiochemicalEntityDetails/Metabolite/ConcentrationDataTable.js - About 45 mins to fix

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

        static getKiValues(parameters) {
          const kis = {};
          for (const parameter of parameters) {
            if (parameter.type === 261 || parameter.sbo_type === 261) {
              if (parameter.value != null) {
      Severity: Minor
      Found in src/scenes/BiochemicalEntityDetails/Reaction/RateConstantsDataTable.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

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

        setModel(model) {
          if (model && "markValueToDistance" in model) {
            this.markValueToDistance = model.markValueToDistance;
          }
      
      
      Severity: Minor
      Found in src/scenes/BiochemicalEntityDetails/TaxonomyFilter.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

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

        static getKcatValues(parameters) {
          for (const parameter of parameters) {
            if (
              parameter.type === 25 ||
              parameter.sbo_type === 25 ||
      Severity: Minor
      Found in src/scenes/BiochemicalEntityDetails/Reaction/RateConstantsDataTable.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

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

        setModel(selectedVals) {
          if (selectedVals == null) {
            selectedVals = new Set();
          }
      
      
      Severity: Minor
      Found in src/scenes/BiochemicalEntityDetails/TextFilter.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

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

        static processRelatedMetabolites(partLinks, metabolites, organism) {
          metabolites.sort((a, b) => {
            return naturalSort(a.name, b.name);
          });
      
      
      Severity: Minor
      Found in src/scenes/BiochemicalEntityDetails/Reaction/MetadataSection.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

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

        static getKmValues(parameters) {
          const kms = {};
          for (const parameter of parameters) {
            if (parameter.type === 27 || parameter.sbo_type === 27) {
              if (parameter.value != null) {
      Severity: Minor
      Found in src/scenes/BiochemicalEntityDetails/Reaction/RateConstantsDataTable.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

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

      function formatChemicalFormula(formula) {
        if (!formula) {
          return null;
        }
      
      
      Severity: Minor
      Found in src/utils/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 value.toFixed(decimals);
      Severity: Major
      Found in src/utils/utils.js - About 30 mins to fix

        Function removeDuplicates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function removeDuplicates(array, keyFunc = null) {
          const uniqueKeyVals = {};
        
          for (const el of array) {
            let key;
        Severity: Minor
        Found in src/utils/utils.js - About 25 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 getUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          getUrl(query, organism) {
            if (isOrthoDbId(query)) {
              const args = ["kegg_id=" + query, "distance=40"];
              if (organism) {
                args.push("anchor=" + organism);
        Severity: Minor
        Found in src/scenes/BiochemicalEntityDetails/Gene/ProteinModificationDataTable.js - About 25 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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          render() {
            if (this.state.metadata && this.state.metadata.error404) {
              return <Error404 />;
            }
        
        
        Severity: Minor
        Found in src/scenes/BiochemicalEntityDetails/Reaction/Reaction.js - About 25 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 formatMetadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          static formatMetadata(query, organism, processedData) {
            const sections = [];
        
            sections.push({
              id: "id",
        Severity: Minor
        Found in src/scenes/BiochemicalEntityDetails/Gene/MetadataSection.js - About 25 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 castToArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function castToArray(obj) {
          if (Array.isArray(obj)) {
            return obj;
          } else {
            if (obj == null || obj === undefined) {
        Severity: Minor
        Found in src/utils/utils.js - About 25 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 isEmpty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function isEmpty(element) {
          if (element instanceof Array) {
            if (element.length === 0) {
              return true;
            }
        Severity: Minor
        Found in src/utils/utils.js - About 25 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