swagger-api/swagger-editor

View on GitHub

Showing 206 of 206 total issues

File index.js has 1514 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export const petStoreOas3Def = `openapi: 3.0.3
info:
  title: Swagger Petstore - OpenAPI 3.0
  description: |-
    This is a sample Pet Store Server based on the OpenAPI 3.0 specification.  You can find out more about
Severity: Major
Found in src/plugins/default-definitions/index.js - About 4 days to fix

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

    export default function getKeywordsForPath({ system, path, keywordMap}) {
      keywordMap = Object.assign({}, keywordMap)
    
      // is getting path was not successful stop here and return no candidates
      if (!isArray(path)) {
    src/plugins/editor-autosuggest-keywords/get-keywords-for-path.js on lines 9..105

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

    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 default function getKeywordsForPath({ system, path, keywordMap }) {
      keywordMap = Object.assign({}, keywordMap)
    
      // is getting path was not successful stop here and return no candidates
      if (!isArray(path)) {
    src/plugins/editor-autosuggest-oas3-keywords/get-keywords-for-path.js on lines 9..105

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

    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 validateOAS3ParameterRefsReferenceParameterPositions = () => sys => {
      return sys.validateSelectors
        .allParameters()
        .then(nodes => {
          return nodes.reduce((acc, node) => {
    Severity: Major
    Found in src/plugins/validate-semantic/validators/oas3/refs.js and 1 other location - About 1 day to fix
    src/plugins/validate-semantic/validators/oas3/refs.js on lines 120..154

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

    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 validateOAS3RefsForHeadersReferenceHeadersPositions = () => sys => {
      return sys.validateSelectors
        .allHeaders()
        .then(nodes => {
          return nodes.reduce((acc, node) => {
    Severity: Major
    Found in src/plugins/validate-semantic/validators/oas3/refs.js and 1 other location - About 1 day to fix
    src/plugins/validate-semantic/validators/oas3/refs.js on lines 84..118

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

    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

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

    function getChild(object, key) {
      var keys = Object.keys(object)
      var regex
      var isArrayAccess = /^\d+$/.test(key)
    
    
    src/plugins/editor-autosuggest-keywords/get-keywords-for-path.js on lines 107..133

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

    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

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

    function getChild(object, key) {
      var keys = Object.keys(object)
      var regex
      var isArrayAccess = /^\d+$/.test(key)
    
    
    src/plugins/editor-autosuggest-oas3-keywords/get-keywords-for-path.js on lines 107..133

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

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

      render() {
        let { specSelectors, getComponent } = this.props
    
        const Modal = getComponent("TopbarModal")
        const Dropdown = getComponent("InsertDropdown")
    Severity: Major
    Found in src/standalone/topbar-insert/topbar-insert.jsx - About 5 hrs to fix

      Function checkForErrors has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      export const checkForErrors = (formData) => {
        let errors = false
      
        // Invalid object was provided.
        if (!OrderedMap.isOrderedMap(formData) && !Map.isMap(formData)) {
      Severity: Minor
      Found in src/standalone/topbar-insert/forms/helpers/validation-helpers.js - About 5 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 getLineNumberForPath has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

      export function getLineNumberForPath(yaml, path) {
      
        // Type check
        if (typeof yaml !== "string") {
          throw new TypeError("yaml should be a string")
      Severity: Minor
      Found in src/plugins/ast/ast.js - About 5 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

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

      function constructAceCompletion(meta, keyword) {
        if(keyword.slice(0, 2) === "__") {
          return {}
        }
      
      
      src/plugins/editor-autosuggest-oas3-keywords/get-keywords-for-path.js on lines 145..172

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

      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

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

      function constructAceCompletion(meta, keyword) {
        if(keyword.slice(0, 2) === "__") {
          return {}
        }
      
      
      src/plugins/editor-autosuggest-keywords/get-keywords-for-path.js on lines 145..172

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

      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

      File selectors.js has 386 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import flatten from "lodash/flatten"
      
      export const isVendorExt = (state,node) => node.path.some(a => a.indexOf("x-") === 0)
      export const isDefinition = (state,node) => node.path[0] == "definitions" && node.path.length == 2
      export const isTag = (state, node) => node.path[0] === "tags" && node.path.length === 2
      Severity: Minor
      Found in src/plugins/validate-semantic/selectors.js - About 5 hrs to fix

        Function pathForPosition has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

        export function pathForPosition(yaml, position) {
        
          // Type check
          if (typeof yaml !== "string") {
            throw new TypeError("yaml should be a string")
        Severity: Minor
        Found in src/plugins/ast/ast.js - About 5 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 validateParameterFormDataConsumesType has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        export const validateParameterFormDataConsumesType = () => system => {
          return system.validateSelectors
            .allPathItems()
            .then(nodes => {
              return nodes.reduce((acc, node) => {
        Severity: Minor
        Found in src/plugins/validate-semantic/validators/form-data.js - About 4 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 validateOAS3RefsForRequestBodiesReferenceRequestBodyPositions has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        export const validateOAS3RefsForRequestBodiesReferenceRequestBodyPositions = () => sys => {
          return sys.validateSelectors
            .allOAS3RequestBodies()
            .then(nodes => {
              return nodes.reduce((acc, node) => {
        Severity: Minor
        Found in src/plugins/validate-semantic/validators/oas3/refs.js - About 4 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

                    { showServersMenu ? <DropdownMenu className="long" {...makeMenuOptions("Generate Server")}>
                      { this.state.servers
                          .map((serv, i) => <li key={i}><button type="button" onClick={() => this.downloadGeneratedFile("server", serv)}>{serv}</button></li>) }
                    </DropdownMenu> : null }
        Severity: Major
        Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 3 hrs to fix
        src/standalone/topbar/components/Topbar.jsx on lines 387..390

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

        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

                    { showClientsMenu ? <DropdownMenu className="long" {...makeMenuOptions("Generate Client")}>
                      { this.state.clients
                          .map((cli, i) => <li key={i}><button type="button" onClick={() => this.downloadGeneratedFile("client", cli)}>{cli}</button></li>) }
                    </DropdownMenu> : null }
        Severity: Major
        Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 3 hrs to fix
        src/standalone/topbar/components/Topbar.jsx on lines 383..386

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

        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

        File Topbar.jsx has 313 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from "react"
        import PropTypes from "prop-types"
        import Swagger from "swagger-client"
        import URL from "url"
        import DropdownMenu from "./DropdownMenu"
        Severity: Minor
        Found in src/standalone/topbar/components/Topbar.jsx - About 3 hrs to fix

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

                  { this.state.showAddExternalDocsModal &&
                    <Modal
                      title="Add External Documentation"
                      onCloseClick={this.closeModalClick("showAddExternalDocsModal")}
                    >
          Severity: Major
          Found in src/standalone/topbar-insert/topbar-insert.jsx and 3 other locations - About 3 hrs to fix
          src/standalone/topbar-insert/topbar-insert.jsx on lines 163..176
          src/standalone/topbar-insert/topbar-insert.jsx on lines 221..234
          src/standalone/topbar-insert/topbar-insert.jsx on lines 235..248

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

          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