reactioncommerce/redoc

View on GitHub

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

                    Line length
                    Open

                    Use `Meteor.settings.public.gitter.room` to configure the [Gitter Sidecar](https://sidecar.gitter.im/) room. To remove Gitter:
                    Severity: Info
                    Found in README.md by markdownlint

                    MD013 - Line length

                    Tags: line_length

                    Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

                    This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

                    This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

                    You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

                    Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

                    Headers should be surrounded by blank lines
                    Open

                    ### Run
                    Severity: Info
                    Found in README.md by markdownlint

                    MD022 - Headers should be surrounded by blank lines

                    Tags: headers, blank_lines

                    Aliases: blanks-around-headers

                    This rule is triggered when headers (any style) are either not preceded or not followed by a blank line:

                    # Header 1
                    Some text
                    
                    Some more text
                    ## Header 2

                    To fix this, ensure that all headers have a blank line both before and after (except where the header is at the beginning or end of the document):

                    # Header 1
                    
                    Some text
                    
                    Some more text
                    
                    ## Header 2

                    Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse headers that don't have a blank line before, and will parse them as regular text.

                    Ordered list item prefix
                    Open

                      12. No Surrender of Others' Freedom.
                    Severity: Info
                    Found in LICENSE.md by markdownlint

                    MD029 - Ordered list item prefix

                    Tags: ol

                    Aliases: ol-prefix

                    Parameters: style ("one", "ordered"; default "one")

                    This rule is triggered on ordered lists that do not either start with '1.' or do not have a prefix that increases in numerical order (depending on the configured style, which defaults to 'one').

                    Example valid list if the style is configured as 'one':

                    1. Do this.
                    1. Do that.
                    1. Done.

                    Example valid list if the style is configured as 'ordered':

                    1. Do this.
                    2. Do that.
                    3. Done.

                    Code block style
                    Open

                        {one line to give the program's name and a brief idea of what it does.}
                    Severity: Info
                    Found in LICENSE.md by markdownlint
                    Severity
                    Category
                    Status
                    Source
                    Language