wordnik/swagger-editor

View on GitHub

Showing 206 of 206 total issues

Function mergeParams has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function mergeParams(objA = {}, objB = {}) {
  if (!objA && !objB) {
    return undefined
  }

Severity: Minor
Found in src/plugins/json-schema-validator/validator/condense-errors.js - 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 getChild has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function getChild(object, key) {
  var keys = Object.keys(object)
  var regex
  var isArrayAccess = /^\d+$/.test(key)

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 validateOAS3HeaderParameterNames has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const validateOAS3HeaderParameterNames = () => (system) => {
  return system.validateSelectors
    .allParameters()
    .then(nodes => {
      return nodes.reduce((acc, node) => {
Severity: Minor
Found in src/plugins/validate-semantic/validators/oas3/parameters.js - 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 getChild has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function getChild(object, key) {
  var keys = Object.keys(object)
  var regex
  var isArrayAccess = /^\d+$/.test(key)

Severity: Minor
Found in src/plugins/editor-autosuggest-keywords/get-keywords-for-path.js - 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 find has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function find(current, path, last) {
    if(!current) {
      // something has gone quite wrong
      // return the last start_mark as a best-effort
      if(last && last.start_mark)
Severity: Minor
Found in src/plugins/ast/ast.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

      if(!res.found && operationsInPathItem.length) {
        operationsInPathItem
          .forEach(op => {
            const inThisOperation = (op.parameters || [])
              .some(param => param.name === paramName && param.in === "path")
    Severity: Critical
    Found in src/plugins/validate-semantic/validators/helpers.js - About 1 hr to fix

      Function default has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function() {
        return {
          afterLoad: system => system.jsonSchemaValidatorActions.setup(),
          statePlugins: {
            jsonSchemaValidator: {
      Severity: Minor
      Found in src/plugins/json-schema-validator/index.js - About 1 hr to fix

        Function getSchemaBasePath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getSchemaBasePath = () => ({ specSelectors }) => {
          // Eg: [openapi-3.0] or [openapi-2-0]
          // later on... ["openapi-2.0", "paths", "get"]
          const isOAS3 = specSelectors.isOAS3 ? specSelectors.isOAS3() : false
          const isSwagger2 = specSelectors.isSwagger2
        Severity: Minor
        Found in src/plugins/json-schema-validator/index.js - 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 default has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function () {
          return {
            statePlugins: {
              topbar: {
                actions: {
        Severity: Minor
        Found in src/standalone/topbar/index.js - About 1 hr to fix

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

              termsofservice: {
                value: existingValues ? existingValues.get("termsofservice") : "", 
                name: "Terms of Service",
                description: "A URL to the Terms of Service for the API. MUST be in the format of a URL.",
                updateForm: newForm => updateForm(newForm, path.concat(["termsofservice"]))
          src/standalone/topbar-insert/forms/form-objects/info-object.js on lines 15..20

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

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

            render() {
              let { specSelectors, getComponent, errSelectors, fn, editorSelectors, configsSelectors } = this.props
          
              let Editor = getComponent("Editor")
          
          
          Severity: Minor
          Found in src/plugins/editor/components/editor-container.jsx - About 1 hr to fix

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

              render() {
                const { menuAlign, align, inverse, size, className } = this.props
            
                const menuClassName = classnames(
                  "dd-menu",
            Severity: Minor
            Found in src/standalone/topbar/components/DropdownMenu.jsx - About 1 hr to fix

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

              export const isOAS3RootSchema = (state, node) => node.path[0] === "components" && node.path[1] === "schemas" && node.path.length === 3
              Severity: Major
              Found in src/plugins/validate-semantic/selectors.js and 3 other locations - About 1 hr to fix
              src/plugins/validate-semantic/selectors.js on lines 18..18
              src/plugins/validate-semantic/selectors.js on lines 19..19
              src/plugins/validate-semantic/selectors.js on lines 21..21

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

              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 4 locations. Consider refactoring.
              Open

              export const isOAS3RootHeader = (state, node) => node.path[0] === "components" && node.path[1] === "headers" && node.path.length === 3
              Severity: Major
              Found in src/plugins/validate-semantic/selectors.js and 3 other locations - About 1 hr to fix
              src/plugins/validate-semantic/selectors.js on lines 18..18
              src/plugins/validate-semantic/selectors.js on lines 19..19
              src/plugins/validate-semantic/selectors.js on lines 20..20

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

              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 4 locations. Consider refactoring.
              Open

              export const isOAS3RootParameter = (state, node) => node.path[0] === "components" && node.path[1] === "parameters" && node.path.length === 3
              Severity: Major
              Found in src/plugins/validate-semantic/selectors.js and 3 other locations - About 1 hr to fix
              src/plugins/validate-semantic/selectors.js on lines 19..19
              src/plugins/validate-semantic/selectors.js on lines 20..20
              src/plugins/validate-semantic/selectors.js on lines 21..21

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

              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

                  description: {
                    value: existingValues ? existingValues.get("description") : "", 
                    name: "Description",
                    description: "A short description of the application. CommonMark syntax MAY be used for rich text representation.",
                    updateForm: newForm => updateForm(newForm, path.concat(["description"]))
              src/standalone/topbar-insert/forms/form-objects/info-object.js on lines 29..34

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

              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 4 locations. Consider refactoring.
              Open

              export const isOAS3RootResponse = (state, node) => node.path[0] === "components" && node.path[1] === "responses" && node.path.length === 3
              Severity: Major
              Found in src/plugins/validate-semantic/selectors.js and 3 other locations - About 1 hr to fix
              src/plugins/validate-semantic/selectors.js on lines 18..18
              src/plugins/validate-semantic/selectors.js on lines 20..20
              src/plugins/validate-semantic/selectors.js on lines 21..21

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

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

              export const validateOAS3HeaderParameterNames = () => (system) => {
                return system.validateSelectors
                  .allParameters()
                  .then(nodes => {
                    return nodes.reduce((acc, node) => {
              Severity: Minor
              Found in src/plugins/validate-semantic/validators/oas3/parameters.js - About 1 hr to fix

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

                      serverGetter({}, {
                        // contextUrl is needed because swagger-client is curently
                        // not building relative server URLs correctly
                        contextUrl: generatorUrl
                      })
                Severity: Major
                Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 1 hr to fix
                src/standalone/topbar/components/Topbar.jsx on lines 63..70

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

                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

                      clientGetter({}, {
                        // contextUrl is needed because swagger-client is curently
                        // not building relative server URLs correctly
                        contextUrl: generatorUrl
                      })
                Severity: Major
                Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 1 hr to fix
                src/standalone/topbar/components/Topbar.jsx on lines 72..79

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

                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