wordnik/swagger-editor

View on GitHub

Showing 206 of 206 total issues

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

        if(typeof minItems === "number" && typeof maxItems === "number" && (minItems > maxItems)) {
          acc.push({
            message: "'minItems' must be lower value than 'maxItems'",
            path: [...node.path, "minItems"],
            level: "error",
Severity: Major
Found in src/plugins/validate-semantic/validators/2and3/schemas.js and 3 other locations - About 1 hr to fix
src/plugins/validate-semantic/validators/2and3/schemas.js on lines 103..109
src/plugins/validate-semantic/validators/2and3/schemas.js on lines 111..117
src/plugins/validate-semantic/validators/2and3/schemas.js on lines 119..125

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

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

export const validateOAS3RefsForHeadersReferenceHeadersPositions = () => sys => {
  return sys.validateSelectors
    .allHeaders()
    .then(nodes => {
      return nodes.reduce((acc, node) => {
Severity: Minor
Found in src/plugins/validate-semantic/validators/oas3/refs.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 validateOAS3ParameterRefsReferenceParameterPositions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const validateOAS3ParameterRefsReferenceParameterPositions = () => sys => {
  return sys.validateSelectors
    .allParameters()
    .then(nodes => {
      return nodes.reduce((acc, node) => {
Severity: Minor
Found in src/plugins/validate-semantic/validators/oas3/refs.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 validate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  validate({ jsSpec, specStr, schemaPath, source }) {
    this.ajv.validate(normalizeKey(schemaPath), jsSpec)

    if (!this.ajv.errors || !this.ajv.errors.length) {
      return null
Severity: Minor
Found in src/plugins/json-schema-validator/validator/index.js - About 1 hr to fix

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

    export default function () {
      const ADD_TO_SPEC = "add_to_spec"
    
      return {
        components: {
    Severity: Minor
    Found in src/standalone/topbar-insert/index.js - About 1 hr to fix

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

            "plugins": [
              [
                "@babel/plugin-transform-runtime",
                {
                  "corejs": "3",
      Severity: Major
      Found in babel.config.js and 1 other location - About 1 hr to fix
      babel.config.js on lines 144..173

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

      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

            "plugins": [
              [
                "@babel/plugin-transform-runtime",
                {
                  "corejs": "3",
      Severity: Major
      Found in babel.config.js and 1 other location - About 1 hr to fix
      babel.config.js on lines 99..128

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

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

      export const validate2And3PathParameterDeclarationHasMatchingDefiniton = () => async system => {
        const nodes = await system.validateSelectors.allPathItems()
      
        return nodes.reduce(async (prev, node) => {
          const acc = await prev
      Severity: Minor
      Found in src/plugins/validate-semantic/validators/2and3/paths.js - About 1 hr to fix

        Function makeTraverseOnce has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function makeTraverseOnce(getSystem) {
          let traversers = {}
          let results = {}
          let deferred = null
        
        
        Severity: Minor
        Found in src/plugins/validate-semantic/index.js - About 1 hr to fix

          Function wrapCompleters has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function wrapCompleters(completers, cutoff = 100) {
            let isLiveCompletionDisabled = false
            let lastSpeeds = []
            let isPerformant = () => lastSpeeds.every(speed => speed < cutoff)
          
          
          Severity: Minor
          Found in src/plugins/editor-autosuggest/helpers.js - About 1 hr to fix

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

            export const addAutosuggestionCompleters = (ori, system) => (context) => {
              return ori(context).concat([{
                getCompletions(...args) {
                  // Add `context`, then `system` as the last args
                  return getCompletions(...args, context, system)
            Severity: Major
            Found in src/plugins/editor-autosuggest-snippets/wrap-actions.js and 3 other locations - About 1 hr to fix
            src/plugins/editor-autosuggest-keywords/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-oas3-keywords/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-refs/wrap-actions.js on lines 4..11

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

            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

                  if ((OrderedMap.isOrderedMap(value) || Map.isMap(value)) && isRequired) {
                    const itemHasErrors = checkForErrors(value)
                    errors = errors || itemHasErrors[1]
                    const newvalue = formItem.set("value", itemHasErrors[0])
                    return newvalue.set("hasErrors", itemHasErrors[1])
            src/standalone/topbar-insert/forms/helpers/validation-helpers.js on lines 87..92

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

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

            export const addAutosuggestionCompleters = (ori, system) => (context) => {
              return ori(context).concat([{
                getCompletions(...args) {
                  // Add `context`, then `system` as the last args
                  return getCompletions(...args, context, system)
            Severity: Major
            Found in src/plugins/editor-autosuggest-refs/wrap-actions.js and 3 other locations - About 1 hr to fix
            src/plugins/editor-autosuggest-keywords/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-oas3-keywords/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-snippets/wrap-actions.js on lines 4..11

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

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

            export const addAutosuggestionCompleters = (ori, system) => (context) => {
              return ori(context).concat([{
                getCompletions(...args) {
                  // Add `context`, then `system` as the last args
                  return getCompletions(...args, context, system)
            src/plugins/editor-autosuggest-keywords/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-refs/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-snippets/wrap-actions.js on lines 4..11

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

            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

                    value.map((item) => {
                      const itemHasErrors = checkForErrors(item)
                      errors = errors || itemHasErrors[1]
                      const newitem = item.set("value", itemHasErrors[0])
                      return newitem.set("hasErrors", itemHasErrors[1])
            src/standalone/topbar-insert/forms/helpers/validation-helpers.js on lines 75..80

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

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

            export const addAutosuggestionCompleters = (ori, system) => (context) => {
              return ori(context).concat([{
                getCompletions(...args) {
                  // Add `context`, then `system` as the last args
                  return getCompletions(...args, context, system)
            Severity: Major
            Found in src/plugins/editor-autosuggest-keywords/wrap-actions.js and 3 other locations - About 1 hr to fix
            src/plugins/editor-autosuggest-oas3-keywords/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-refs/wrap-actions.js on lines 4..11
            src/plugins/editor-autosuggest-snippets/wrap-actions.js on lines 4..11

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

            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 validate2And3MinAndMax has 37 lines of code (exceeds 25 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 1 hr to fix

              Function validate2And3PathParameterIsDefinedInPath has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const validate2And3PathParameterIsDefinedInPath = () => (system) => {
                const refArray = []
                return system.validateSelectors
                  .allParameters()
                  .then(nodes => {
              Severity: Minor
              Found in src/plugins/validate-semantic/validators/2and3/parameters.js - About 1 hr to fix

                Function spec has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function spec() {
                  return {
                    statePlugins: {
                      spec: {
                        selectors: {
                Severity: Minor
                Found in src/plugins/jump-to-path/spec.js - About 1 hr to fix

                  Function validateOAS3RefsForRequestBodiesReferenceRequestBodyPositions has 36 lines of code (exceeds 25 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 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language