CodeTheChangeUBC/sasc

View on GitHub
client/src/Containers/Account/index.js

Summary

Maintainability
F
3 days
Test Coverage

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

    render() {
        if (this.props.auth === "user") {
            return (
                <div className="Account">
                    <h2>User Account Information</h2>
Severity: Major
Found in client/src/Containers/Account/index.js - About 3 hrs to fix

    File index.js has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { Component } from "react";
    import { connect } from "react-redux";
    import { Link } from "react-router-dom";
    import { bindActionCreators } from "redux";
    import Form from "./../../Components/Form";
    Severity: Minor
    Found in client/src/Containers/Account/index.js - About 3 hrs to fix

      Function validateForm has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          validateForm(fields, renderError) {
              const { password, passwordConfirm } = this.state;
      
              if (password !== passwordConfirm) {
                  renderError("Passwords must match.");
      Severity: Minor
      Found in client/src/Containers/Account/index.js - About 1 hr to fix

        Function handleOnSubmit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            handleOnSubmit(ev) {
                ev.preventDefault();
                var ID;
                var fields;
                var validated = false;
        Severity: Minor
        Found in client/src/Containers/Account/index.js - About 1 hr to fix

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

              validateForm(fields, renderError) {
                  const { password, passwordConfirm } = this.state;
          
                  if (password !== passwordConfirm) {
                      renderError("Passwords must match.");
          Severity: Minor
          Found in client/src/Containers/Account/index.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

          Consider simplifying this complex logical expression.
          Open

                      if (
                          !nickname ||
                          !age ||
                          !gender ||
                          !email ||
          Severity: Major
          Found in client/src/Containers/Account/index.js - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                    return fields;
            Severity: Major
            Found in client/src/Containers/Account/index.js - About 30 mins to fix

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

                  handleOnSubmit(ev) {
                      ev.preventDefault();
                      var ID;
                      var fields;
                      var validated = false;
              Severity: Minor
              Found in client/src/Containers/Account/index.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 2 locations. Consider refactoring.
              Open

                  renderAlert() {
                      if (this.props.counsellorStatus.error) {
                          return (
                              <div className="error">{this.props.counsellorStatus.error}</div>
                          );
              Severity: Major
              Found in client/src/Containers/Account/index.js and 1 other location - About 1 day to fix
              client/src/Containers/PasswordChange/index.js on lines 100..118

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

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

              function mapStateToProps(state) {
                  return {
                      auth: state.auth.auth,
                      user: state.user.user,
                      counsellor: state.counsellor.counsellor,
              Severity: Major
              Found in client/src/Containers/Account/index.js and 1 other location - About 2 hrs to fix
              client/src/Containers/PasswordChange/index.js on lines 143..151

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

              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

              function mapDispatchToProps(dispatch) {
                  return bindActionCreators(
                      {
                          getUser: userActions.getUser,
                          updateUser: userActions.updateUser,
              Severity: Major
              Found in client/src/Containers/Account/index.js and 1 other location - About 1 hr to fix
              client/src/Containers/Logout/index.js on lines 45..57

              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

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

                  handleOnChange(event) {
                      const target = event.target;
                      const value = target.value;
                      const name = target.name;
              
              
              Severity: Major
              Found in client/src/Containers/Account/index.js and 7 other locations - About 1 hr to fix
              client/src/Containers/Login/index.js on lines 28..36
              client/src/Containers/LoginCounsellor/index.js on lines 27..35
              client/src/Containers/PasswordChange/index.js on lines 33..41
              client/src/Containers/PreChatSurvey/index.js on lines 30..38
              client/src/Containers/Register/index.js on lines 47..55
              client/src/Containers/RegisterCounsellor/index.js on lines 61..69
              client/src/Containers/Sms/index.js on lines 30..38

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

              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

                                  <div className="change-your-password-here">
                                      <p>
                                          Change your password{" "}
                                          <Link to="/changepassword">here</Link>.
                                      </p>
              Severity: Major
              Found in client/src/Containers/Account/index.js and 2 other locations - About 50 mins to fix
              client/src/Containers/Account/index.js on lines 212..217
              client/src/Containers/Login/index.js on lines 64..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 52.

              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

                                  <div className="change-your-password-here">
                                      <p>
                                          Change your password{" "}
                                          <Link to="/changepassword">here</Link>.
                                      </p>
              Severity: Major
              Found in client/src/Containers/Account/index.js and 2 other locations - About 50 mins to fix
              client/src/Containers/Account/index.js on lines 250..255
              client/src/Containers/Login/index.js on lines 64..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 52.

              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