grommet/grommet-ferret

View on GitHub
src/js/components/virtualMachine/VirtualMachineAdd.js

Summary

Maintainability
F
5 days
Test Coverage

File VirtualMachineAdd.js has 469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { addMultipleVms, loadVmSizes, loadVmImages,
Severity: Minor
Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 7 hrs to fix

    Function _renderNameFields has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _renderNameFields () {
        const { count, naming, template, errors } = this.state;
        let nameFields;
        if (1 === count) {
    
    
    Severity: Major
    Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 2 hrs to fix

      VirtualMachineAdd has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class VirtualMachineAdd extends Component {
      
        constructor (props) {
          super(props);
          this._onSubmit = this._onSubmit.bind(this);
      Severity: Minor
      Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 2 hrs to fix

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

          _renderLayer () {
            const { addNetwork, editNetworkIndex, layer, template } = this.state;
            let result;
            if (layer) {
              if ('network' === layer) {
        Severity: Minor
        Found in src/js/components/virtualMachine/VirtualMachineAdd.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 constructor has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor (props) {
            super(props);
            this._onSubmit = this._onSubmit.bind(this);
            this._onLayerOpen = this._onLayerOpen.bind(this);
            this._onLayerClose = this._onLayerClose.bind(this);
        Severity: Minor
        Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 1 hr to fix

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

            render () {
          
              const countField = this._renderCountField();
              const nameFields = this._renderNameFields();
              const sizeFields = this._renderSizeFields();
          Severity: Minor
          Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 1 hr to fix

            Function _onSubmit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _onSubmit (event) {
                event.preventDefault();
                const { router } = this.context;
                const { count, template } = this.state;
                let errors = {};
            Severity: Minor
            Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 1 hr to fix

              Function _renderNetworkFields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _renderNetworkFields () {
                  const { template } = this.state;
                  const networks = template.networks.map((network, index) => {
                    return (
                      <ListItem key={index} justify="between" pad="none"
              Severity: Minor
              Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 1 hr to fix

                Function _onSubmit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  _onSubmit (event) {
                    event.preventDefault();
                    const { router } = this.context;
                    const { count, template } = this.state;
                    let errors = {};
                Severity: Minor
                Found in src/js/components/virtualMachine/VirtualMachineAdd.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 _renderSizeTiles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _renderSizeTiles () {
                    const { sizes, template, errors } = this.state;
                    let selectedIndex;
                    const sizeTiles = sizes.map((size, index) => {
                      if (size.name === template.size.name) {
                Severity: Minor
                Found in src/js/components/virtualMachine/VirtualMachineAdd.js - About 1 hr to fix

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

                    _renderNameFields () {
                      const { count, naming, template, errors } = this.state;
                      let nameFields;
                      if (1 === count) {
                  
                  
                  Severity: Minor
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.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

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

                      const networks = template.networks.map((network, index) => {
                        return (
                          <ListItem key={index} justify="between" pad="none"
                            separator={index === 0 ? 'horizontal' : 'bottom'}
                            responsive={false}>
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 6 hrs to fix
                  src/js/components/virtualMachine/VirtualMachineEdit.js on lines 232..246

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

                  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

                      return (
                        <fieldset>
                          <Header size="small" justify="between">
                            <Heading tag="h3">Networks</Heading>
                            <Button icon={<AddIcon />} onClick={this._onNetworkAdd}
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 3 hrs to fix
                  src/js/components/virtualMachine/VirtualMachineEdit.js on lines 247..258

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

                  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

                                <FormField label="Start numbering with" htmlFor="nameStart">
                                  <input id="nameStart" name="naming.start" type="number"
                                    value={naming.start}
                                    onChange={this._change('naming', 'prefix')} />
                                </FormField>
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 1 hr to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 293..297

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

                  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

                                <FormField label="Prefix" htmlFor="namePrefix">
                                  <input id="namePrefix" name="naming.prefix" type="text"
                                    value={naming.prefix}
                                    onChange={this._change('naming', 'prefix')} />
                                </FormField>
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 1 hr to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 298..302

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

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

                            <RadioButton id="nameStrategyPrefix" name="naming.type"
                              label="Add a name prefix"
                              value="prefix"
                              checked={'prefix' === naming.type}
                              onChange={this._change('naming', 'type')}/>
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 2 other locations - About 1 hr to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 275..279
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 280..284

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

                            <RadioButton id="nameStrategyExtend" name="naming.type"
                              label="Extend an existing set of virtual machines"
                              value="extend"
                              checked={'extend' === naming.type}
                              onChange={this._change('naming', 'type')}/>
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 2 other locations - About 1 hr to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 270..274
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 275..279

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

                            <RadioButton id="nameStrategyManual" name="naming.type"
                              label="Provide each individual name"
                              value="manual"
                              checked={'manual' === naming.type}
                              onChange={this._change('naming', 'type')}/>
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 2 other locations - About 1 hr to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 270..274
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 280..284

                  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

                          result = (
                            <VirtualMachineEditNetwork onClose={this._onLayerClose}
                              heading={heading}
                              network={network} onChange={this._onNetworkChange}
                              onRemove={onRemove} />
                  Severity: Major
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 1 hr to fix
                  src/js/components/virtualMachine/VirtualMachineEdit.js on lines 270..275

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

                  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

                        } else {
                          this.props.dispatch(addMultipleVms(this.props.count, this.props.naming,
                            this.props.template));
                        }
                  Severity: Minor
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 40 mins to fix
                  src/js/components/Utilization.js on lines 155..158

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

                  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 (! template.image || ! template.image.uri) {
                        errors.image = 'required';
                        noErrors = false;
                      }
                  Severity: Minor
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 30 mins to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 99..102

                  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 (! template.size || ! template.size.name) {
                        errors.size = 'required';
                        noErrors = false;
                      }
                  Severity: Minor
                  Found in src/js/components/virtualMachine/VirtualMachineAdd.js and 1 other location - About 30 mins to fix
                  src/js/components/virtualMachine/VirtualMachineAdd.js on lines 103..106

                  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

                  There are no issues that match your filters.

                  Category
                  Status