wordnik/swagger-editor

View on GitHub

Showing 206 of 206 total issues

Function validateOAS3GetAndDeleteOpsHaveNoRequestBody has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const validateOAS3GetAndDeleteOpsHaveNoRequestBody = () => sys => {
  return sys.validateSelectors
    .allOperations()
    .then(nodes => {
      return nodes.reduce((acc, node) => {
Severity: Minor
Found in src/plugins/validate-semantic/validators/oas3/operations.js - About 35 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 buildConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function buildConfig(
  {
    minimize = true,
    mangle = true,
    sourcemaps = true,
Severity: Minor
Found in webpack/_config-builder.js - About 35 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 default has a Cognitive Complexity of 7 (exceeds 5 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 35 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 isParameterSchema has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const isParameterSchema = (state, node) => (sys) => {
  if(sys.specSelectors.isOAS3 && sys.specSelectors.isOAS3()) {
    // OAS3
    return node.key === "schema" && sys.validateSelectors.isParameter(node.parent)
  }
Severity: Minor
Found in src/plugins/validate-semantic/selectors.js - About 35 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 Dropzone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const Dropzone = ({ children, onDrop }) => {
  const handleDrop = useCallback((acceptedFiles, rejectedFiles) => {
    const someFilesWereRejected = rejectedFiles && rejectedFiles.length > 0
    const thereIsExactlyOneAcceptedFile = acceptedFiles && acceptedFiles.length === 1

Severity: Minor
Found in src/layout.jsx - About 35 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

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

    node.path[0] === "paths"
      && node.path[3] === "responses"
      && node.path.length === 5
      && !sys.validateSelectors.isVendorExt(node)
Severity: Minor
Found in src/plugins/validate-semantic/selectors.js and 1 other location - About 35 mins to fix
src/plugins/validate-semantic/selectors.js on lines 382..385

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

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

        node.path[0] == "paths"
          && node.path[3] == "security"
          && node.path.length === 5
          && !system.validateSelectors.isVendorExt(node.parent) // ignore extension keys in path items
Severity: Minor
Found in src/plugins/validate-semantic/selectors.js and 1 other location - About 35 mins to fix
src/plugins/validate-semantic/selectors.js on lines 98..101

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

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

Avoid too many return statements within this function.
Open

      return formItem.set("hasErrors", validationResult)
Severity: Major
Found in src/standalone/topbar-insert/forms/helpers/validation-helpers.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return true
    Severity: Major
    Found in src/plugins/editor/components/editor.jsx - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return keywordMap.map(constructAceCompletion.bind(null, "value"))
      Severity: Major
      Found in src/plugins/editor-autosuggest-oas3-keywords/get-keywords-for-path.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return find(item, path.slice(1), current.value)
        Severity: Major
        Found in src/plugins/ast/ast.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return current.start_mark.line + 1
          Severity: Major
          Found in src/plugins/ast/ast.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return path
            Severity: Major
            Found in src/plugins/ast/ast.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return null
              Severity: Major
              Found in src/standalone/topbar-menu-edit-convert/components/convert-modal.jsx - About 30 mins to fix

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

                    description: {
                      value: "",
                      name: "Description",
                      description: "A short description of the tag. CommonMark syntax MAY be used for rich text representation.",
                      updateForm: newForm => updateForm(newForm, path.concat(["description"]))
                Severity: Major
                Found in src/standalone/topbar-insert/forms/form-objects/tag-object.js and 3 other locations - About 30 mins to fix
                src/standalone/topbar-insert/forms/form-objects/external-documentation-object.js on lines 13..18
                src/standalone/topbar-insert/forms/form-objects/operation-object.js on lines 50..55
                src/standalone/topbar-insert/forms/form-objects/path-object.js on lines 21..26

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

                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

                Avoid too many return statements within this function.
                Open

                    return []
                Severity: Major
                Found in src/plugins/editor-autosuggest-oas3-keywords/get-keywords-for-path.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return suggestionFromSchema(keywordMap)
                  Severity: Major
                  Found in src/plugins/editor-autosuggest-oas3-keywords/get-keywords-for-path.js - About 30 mins to fix

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

                        description: {
                          value: "",
                          name: "Description",
                          description: "An optional, string description, intended to apply to all operations in this path. CommonMark syntax MAY be used for rich text representation.",
                          updateForm: event => updateForm(event, path.concat(["description"]))
                    Severity: Major
                    Found in src/standalone/topbar-insert/forms/form-objects/path-object.js and 3 other locations - About 30 mins to fix
                    src/standalone/topbar-insert/forms/form-objects/external-documentation-object.js on lines 13..18
                    src/standalone/topbar-insert/forms/form-objects/operation-object.js on lines 50..55
                    src/standalone/topbar-insert/forms/form-objects/tag-object.js on lines 14..19

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

                    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

                        description: {
                          value: "",
                          name: "Description",
                          description: "A short description of the target documentation. CommonMark syntax MAY be used for rich text representation.",
                          updateForm: event => updateForm(event, path.concat(["description"]))
                    src/standalone/topbar-insert/forms/form-objects/operation-object.js on lines 50..55
                    src/standalone/topbar-insert/forms/form-objects/path-object.js on lines 21..26
                    src/standalone/topbar-insert/forms/form-objects/tag-object.js on lines 14..19

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

                    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(typeof pattern === "string" && pattern.indexOf("\\Z") > -1) {
                              acc.push({
                                message: `"\\Z" anchors are not allowed in regular expression patterns`,
                                path: [...node.path, "pattern"],
                                level: "error",
                    Severity: Minor
                    Found in src/plugins/validate-semantic/validators/schema.js and 1 other location - About 30 mins to fix
                    src/plugins/validate-semantic/validators/schema.js on lines 8..14

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

                    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