swagger-api/swagger-editor

View on GitHub
src/standalone/topbar/components/Topbar.jsx

Summary

Maintainability
F
3 days
Test Coverage

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

    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

      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

        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

        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

                      {isJson ? [
                          <li key="1"><button type="button" onClick={this.saveAsJson}>Save as JSON</button></li>,
                          <li key="2"><button type="button" onClick={this.saveAsYaml}>Convert and save as YAML</button></li>
                      ] : [
        Severity: Major
        Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 2 hrs to fix
        src/standalone/topbar/components/Topbar.jsx on lines 364..367

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

        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

                      ] : [
                          <li key="1"><button type="button" onClick={this.saveAsYaml}>Save as YAML</button></li>,
                          <li key="2"><button type="button" onClick={this.saveAsJson}>Convert and save as JSON</button></li>
                      ]}
        Severity: Major
        Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 2 hrs to fix
        src/standalone/topbar/components/Topbar.jsx on lines 361..364

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

        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

        Topbar.propTypes = {
          specSelectors: PropTypes.object.isRequired,
          errSelectors: PropTypes.object.isRequired,
          specActions: PropTypes.object.isRequired,
          topbarActions: PropTypes.object.isRequired,
        Severity: Major
        Found in src/standalone/topbar/components/Topbar.jsx and 1 other location - About 2 hrs to fix
        src/layout.jsx on lines 71..78

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

        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

        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

        There are no issues that match your filters.

        Category
        Status