grommet/grommet-ferret

View on GitHub
src/js/components/settings/DirectoryEdit.js

Summary

Maintainability
F
5 days
Test Coverage

File DirectoryEdit.js has 406 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 { changeDirectory, loadDirectoryCertificate, trustDirectory,
Severity: Minor
Found in src/js/components/settings/DirectoryEdit.js - About 5 hrs to fix

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

      _onSubmit () {
        const { directory, phase } = this.props;
        const { credentials, needCredentials } = this.state;
        let errors = {...this.state.errors};
        let noErrors = true;
    Severity: Minor
    Found in src/js/components/settings/DirectoryEdit.js - About 5 hrs 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 componentWillReceiveProps has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      componentWillReceiveProps (nextProps) {
        var { directory, phase, response, roles } = nextProps;
        if (directory.certificate && 'Connecting' === this.state.busy) {
          this.setState({ busy: undefined });
        } else if ('search' === phase && 'Verifying' === this.state.busy) {
    Severity: Minor
    Found in src/js/components/settings/DirectoryEdit.js - About 2 hrs 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 _onSubmit has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _onSubmit () {
        const { directory, phase } = this.props;
        const { credentials, needCredentials } = this.state;
        let errors = {...this.state.errors};
        let noErrors = true;
    Severity: Major
    Found in src/js/components/settings/DirectoryEdit.js - About 2 hrs to fix

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

        _renderBaseFields () {
          const { directory, phase, productName, settings } = this.props;
          const { errors } = this.state;
      
          let directoryErrors;
      Severity: Minor
      Found in src/js/components/settings/DirectoryEdit.js - About 1 hr to fix

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

          _renderRole (role) {
            const { directory, search, searchResponse } = this.props;
            let groups = [];
            directory.groups.forEach((group, index) => {
              if (group.role === role) {
        Severity: Minor
        Found in src/js/components/settings/DirectoryEdit.js - About 1 hr to fix

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

            _renderForm () {
              const { phase } = this.props;
          
              let summary;
              let contents;
          Severity: Minor
          Found in src/js/components/settings/DirectoryEdit.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (! credentials.userName) {
                        errors.userName = 'required';
                        noErrors = false;
                      }
            Severity: Major
            Found in src/js/components/settings/DirectoryEdit.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          while (usedRoles[roles[index]]) index += 1;
              Severity: Major
              Found in src/js/components/settings/DirectoryEdit.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if (! credentials.password) {
                            errors.password = 'required';
                            noErrors = false;
                          }
                Severity: Major
                Found in src/js/components/settings/DirectoryEdit.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (credentials) {
                              this.setState({ needCredentials: false, credentials: null,
                                editBase: false, busy: 'Verifying' });
                              this.props.dispatch(verifyDirectory(directory, credentials));
                            } else {
                  Severity: Major
                  Found in src/js/components/settings/DirectoryEdit.js - About 45 mins to fix

                    Function _onChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      _onChange (event) {
                        let directory = { ...this.props.directory };
                        let errors = { ...this.state.errors };
                        const attribute = event.target.getAttribute('name');
                        const value = event.target.value;
                    Severity: Minor
                    Found in src/js/components/settings/DirectoryEdit.js - About 25 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 4 locations. Consider refactoring.
                    Open

                      _onCredentialsChange (event) {
                        let credentials = { ...this.state.credentials };
                        let errors = { ...this.state.errors };
                        const attribute = event.target.getAttribute('name');
                        const value = event.target.value;
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 3 other locations - About 4 hrs to fix
                    src/js/components/image/ImageForm.js on lines 63..71
                    src/js/components/settings/AccountEdit.js on lines 43..51
                    src/js/components/virtualMachine/VirtualMachineEditNetwork.js on lines 60..68

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

                    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

                              <FormField htmlFor="password" label="Password"
                                error={errors.password}>
                                <input id="password" name="password" type="password"
                                  value={credentials.password || ''}
                                  onChange={this._onCredentialsChange} />
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 3 other locations - About 2 hrs to fix
                    src/js/components/settings/DirectoryEdit.js on lines 257..262
                    src/js/components/settings/DirectoryEdit.js on lines 279..284
                    src/js/components/settings/DirectoryEdit.js on lines 317..322

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

                    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

                            <FormField htmlFor="baseDn"
                              label="Base distinguished name (DN). For example: ou=groups,o=my.com"
                              error={errors.baseDn}>
                              <input id="baseDn" name="baseDn" type="text"
                                value={directory.baseDn || ''} onChange={this._onChange} />
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 3 other locations - About 2 hrs to fix
                    src/js/components/settings/DirectoryEdit.js on lines 279..284
                    src/js/components/settings/DirectoryEdit.js on lines 317..322
                    src/js/components/settings/DirectoryEdit.js on lines 323..328

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

                    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

                            <FormField htmlFor="address"
                              label="Directory server host name or IP address. A :port is optional."
                              error={errors.address}>
                              <input id="address" name="address" type="text"
                                value={directory.address || ''} onChange={this._onChange} />
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 3 other locations - About 2 hrs to fix
                    src/js/components/settings/DirectoryEdit.js on lines 257..262
                    src/js/components/settings/DirectoryEdit.js on lines 317..322
                    src/js/components/settings/DirectoryEdit.js on lines 323..328

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

                    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

                              <FormField htmlFor="userName" label="User name"
                                error={errors.userName}>
                                <input id="userName" name="userName" type="text"
                                  value={credentials.userName || ''}
                                  onChange={this._onCredentialsChange} />
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 3 other locations - About 2 hrs to fix
                    src/js/components/settings/DirectoryEdit.js on lines 257..262
                    src/js/components/settings/DirectoryEdit.js on lines 279..284
                    src/js/components/settings/DirectoryEdit.js on lines 323..328

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

                    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

                              <RadioButton id="type-ldap" label="LDAP" name="type"
                                checked={'ldap' === directory.type}
                                onChange={this._onTypeChange.bind(this, 'ldap')} />
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 1 other location - About 1 hr to fix
                    src/js/components/settings/DirectoryEdit.js on lines 275..277

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

                    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

                              <RadioButton id="type-ad" label="Active Directory" name="type"
                                checked={'active directory' === directory.type}
                                onChange={this._onTypeChange.bind(this, 'active directory')} />
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 1 other location - About 1 hr to fix
                    src/js/components/settings/DirectoryEdit.js on lines 272..274

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

                    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

                        if (settings.errors && settings.errors.directory) {
                          directoryErrors = <ErrorList errors={settings.errors.directory} />;
                        }
                    Severity: Major
                    Found in src/js/components/settings/DirectoryEdit.js and 3 other locations - About 50 mins to fix
                    src/js/components/settings/HypervisorEdit.js on lines 103..105
                    src/js/components/settings/IdentityEdit.js on lines 64..66
                    src/js/components/settings/NodesEdit.js on lines 213..215

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

                    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

                      _renderCertificate (certificate) {
                        return (
                          <Certificate certificate={certificate}
                            onTrust={this._onTrust} onDontTrust={this._onDontTrust} />
                        );
                    Severity: Minor
                    Found in src/js/components/settings/DirectoryEdit.js and 1 other location - About 35 mins to fix
                    src/js/components/settings/HypervisorEdit.js on lines 90..95

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

                    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