reactioncommerce/redoc

View on GitHub

Showing 36 of 186 total issues

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

  render() {
    return (
      <div className="redoc page">
        <Helmet
          meta={[
Severity: Minor
Found in common/components/layout.jsx - About 1 hr to fix

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

      scrollToElement() {
        if (Meteor.isClient) {
          if (window.location.hash) {
            const hashParts = window.location.hash.split("#");
    
    
    Severity: Minor
    Found in common/components/docs.jsx - 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 renderContent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      renderContent() {
        if (Meteor.isClient && DocSearch.getCurrentQuery()) {
          if (DocSearch.getCurrentQuery().length > 0) {
            return (
              <SearchResults
    Severity: Minor
    Found in common/components/docs.jsx - About 1 hr to fix

      Function constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        constructor(props) {
          super(props);
          this.displayName = "Search Field";
          this.state = {
            showClearButton: false
      Severity: Minor
      Found in common/components/search.jsx - About 55 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 replaceLink has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        replaceLink: (link, env) => {
          const isImage = link.search(/([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif))/i) > -1;
          const hasProtocol = link.search(/^http[s]?\:\/\//) > -1;
          let newLink = link;
          if (isImage && !hasProtocol) {
      Severity: Minor
      Found in packages/redoc-core/server/methods/processDoc.js - About 55 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 (toc) {
                  if (Array.isArray(toc.tocData)) {
                    // Loop through all entries and add them to the TOC collection
                    toc.tocData.forEach((tocItem, index) => {
                      const filename = tocItem.docPath.split("/").pop().replace(/\.[^/.]+$/, "");
      Severity: Major
      Found in packages/redoc-core/server/methods/repoData.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if (_.isFunction(md.options.processTOCHeadings)) {
                          md.options.processTOCHeadings(data, state.env);
                        }
        Severity: Major
        Found in packages/redoc-core/lib/plugins/toc.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if (!isBlankString(node.content)) {
                            documentTOC.push({
                              className: `guide-sub-subnav-item level-${headingLevel}`,
                              label: node.content || "--",
                              slug
          Severity: Major
          Found in packages/redoc-core/lib/plugins/toc.js - About 45 mins to fix

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

            SearchSource.prototype.getData = function (options, getCursor) {
              options = options || {};
              const self = this;
              this._storeDep.depend();
              let selector = {$or: []};
            Severity: Minor
            Found in packages/search-source/lib/client.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 (service === "github") {
                        authString = `?client_id=${settings.clientId}&client_secret=${settings.secret}`;
                      }
            Severity: Major
            Found in packages/redoc-core/server/methods/repoData.js - About 45 mins to fix

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

                renderContent() {
                  if (Meteor.isClient && DocSearch.getCurrentQuery()) {
                    if (DocSearch.getCurrentQuery().length > 0) {
                      return (
                        <SearchResults
              Severity: Minor
              Found in common/components/docs.jsx - 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 (Array.isArray(toc.tocData)) {
                          // Loop through all entries and add them to the TOC collection
                          toc.tocData.forEach((tocItem, index) => {
                            const filename = tocItem.docPath.split("/").pop().replace(/\.[^/.]+$/, "");
              
              
              Severity: Major
              Found in packages/redoc-core/server/methods/repoData.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if (_.contains(getPublicBranches(), branch.name)) {
                            const docCount = ReDoc.Collections.Docs.find({
                              repo: repo.repo,
                              branch: branch.name
                            }).count();
                Severity: Major
                Found in packages/redoc-core/server/methods/repoData.js - About 45 mins to fix

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

                    render() {
                      // Render admin dashboard
                      if (Meteor.userId()) {
                        let badges = [];
                  
                  
                  Severity: Minor
                  Found in packages/redoc-core/components/admin.jsx - 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 (this.context.router) {
                        const branch = selectedBranch || this.props.params.branch || Meteor.settings.public.redoc.branch || "master";
                        const params = this.props.params;
                        const repo = params.repo || this.data.defaultDoc.repo;
                        const alias = params.alias || this.data.defaultDoc.alias;
                  Severity: Major
                  Found in common/components/header.jsx - About 40 mins to fix

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

                    function getRepoData() {
                      let repoData;
                    
                      if (Meteor.settings.redoc && Meteor.settings.redoc.initRepoData) {
                        // If the `initRepoData` key is a string, then fetch the repo data from that URL
                    Severity: Minor
                    Found in packages/redoc-core/server/methods/repoData.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