swagger-api/swagger-editor

View on GitHub

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

    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

      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

        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

          File oas3-objects.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Adapted from OAS 3.0.0-rc2
          
          // comma dangles in this file = cleaner diffs
          /*eslint comma-dangle: ["error", "always-multiline"]*/
          
          
          Severity: Minor
          Found in src/plugins/editor-autosuggest-oas3-keywords/oas3-objects.js - About 2 hrs to fix

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

              render() {
                let { getComponent, specSelectors, topbarActions } = this.props
                const Link = getComponent("Link")
                const TopbarInsert = getComponent("TopbarInsert")
                const ImportFileMenuItem = getComponent("ImportFileMenuItem")
            Severity: Major
            Found in src/standalone/topbar/components/Topbar.jsx - About 2 hrs to fix

              Function positionRangeForPath has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              export function positionRangeForPath(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 2 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 pathForPosition has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function pathForPosition(yaml, position) {
              
                // Type check
                if (typeof yaml !== "string") {
                  throw new TypeError("yaml should be a string")
              Severity: Major
              Found in src/plugins/ast/ast.js - About 2 hrs to fix

                File topbar-insert.jsx has 274 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { Component } from "react"
                import PropTypes from "prop-types"
                
                import { pathForm, pathObject } from "./forms/form-objects/path-object"
                import { operationForm, operationObject } from "./forms/form-objects/operation-object"
                Severity: Minor
                Found in src/standalone/topbar-insert/topbar-insert.jsx - About 2 hrs to fix

                  Topbar has 23 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export default class Topbar extends React.Component {
                    constructor(props, context) {
                      super(props, context)
                  
                      this.state = {
                  Severity: Minor
                  Found in src/standalone/topbar/components/Topbar.jsx - About 2 hrs to fix

                    Function positionRangeForPath has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function positionRangeForPath(yaml, path) {
                    
                      // Type check
                      if (typeof yaml !== "string") {
                        throw new TypeError("yaml should be a string")
                    Severity: Major
                    Found in src/plugins/ast/ast.js - About 2 hrs to fix

                      Function checkForErrors has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const checkForErrors = (formData) => {
                        let errors = false
                      
                        // Invalid object was provided.
                        if (!OrderedMap.isOrderedMap(formData) && !Map.isMap(formData)) {
                      Severity: Major
                      Found in src/standalone/topbar-insert/forms/helpers/validation-helpers.js - About 2 hrs to fix

                        Function validate2And3MinAndMax has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const validate2And3MinAndMax = () => (system) => {
                          return system.validateSelectors
                            .allSchemas()
                            .then(nodes => {
                              return nodes.reduce((acc, node) => {
                        Severity: Minor
                        Found in src/plugins/validate-semantic/validators/2and3/schemas.js - About 2 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 condenseErrors has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function condenseErrors(errors) {
                          if (!Array.isArray(errors)) {
                            return []
                          }
                        
                        
                        Severity: Major
                        Found in src/plugins/json-schema-validator/validator/condense-errors.js - About 2 hrs to fix

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

                            render() { 
                              let addedOption = <span />
                              const addButton = <a role="button" className="d-inline-block float-right" onClick={this.showAddField} onKeyDown={this.onEnterKeyPress} tabIndex={0}>Add</a>
                              if (this.props.isValidAddition) {
                                if (this.state.showAddOption) {
                          Severity: Major
                          Found in src/standalone/topbar-insert/forms/components/FormDropdown.jsx - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language