CodeTheChangeUBC/sasc

View on GitHub

Showing 49 of 160 total issues

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

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

      import React from "react";
      import PropTypes from "prop-types";
      
      const Form = ({
          username,
      Severity: Minor
      Found in client/src/Components/Form/index.js - About 2 hrs to fix

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

            render() {
                if (this.props.auth === "counsellor") {
                    return (
                        <div className="Sms">
                            <h2>SMS Settings</h2>
        Severity: Minor
        Found in client/src/Containers/Sms/index.js - About 2 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 default has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function(state = initialState.user, action) {
                switch (action.type) {
                case SUBMIT_SURVEY:
                    return {
                        ...state,
            Severity: Minor
            Found in client/src/Redux/Reducers/userReducer.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 server has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.server = function(database, databaseMode) {
                  // DB setup
                  database.connect(databaseMode, function(err) {
                    if (err) {
                      console.log('Unable to connect to MySQL.');
                Severity: Minor
                Found in server.js - About 1 hr to fix

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

                  export default function(state = initialState.counsellor, action) {
                      switch (action.type) {
                      case ADD_COUNSELLOR:
                          return {
                              ...state,
                  Severity: Minor
                  Found in client/src/Redux/Reducers/counsellorReducer.js - About 1 hr to fix

                    Function abstractSignup has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function abstractSignup(user, requiredCredentials, role, res, model) {
                        var error = false;
                        var missingCredentials = [];
                    
                        Object.keys(requiredCredentials).forEach(function (property) {
                    Severity: Minor
                    Found in server/controllers/authentication.js - About 1 hr to fix

                      Function changePassword has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.changePassword = async function (req, res, model) {
                          var id = req.query.ID;
                          var oldPassword = req.body.oldPassword;
                      
                          let err, oldPasswordHashed, newPasswordHashed, users, isMatch;
                      Severity: Minor
                      Found in server/controllers/account.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

                        Function getCounsellor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function getCounsellor(id) {
                            return function(dispatch) {
                                const token = localStorage.getItem("token");
                                const header = {
                                    headers: {
                        Severity: Minor
                        Found in client/src/Redux/Actions/counsellorActions.js - About 1 hr to fix

                          Function default has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function(state = initialState.sms, action) {
                              switch (action.type) {
                              case GET_SMS_SETTINGS:
                                  return {
                                      ...state,
                          Severity: Minor
                          Found in client/src/Redux/Reducers/smsReducer.js - About 1 hr to fix

                            Function getUser has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function getUser(id) {
                                return function(dispatch) {
                                    const token = localStorage.getItem("token");
                                    const header = {
                                        headers: {
                            Severity: Minor
                            Found in client/src/Redux/Actions/userActions.js - About 1 hr to fix

                              Function default has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export default function(state = initialState.auth, action) {
                                  switch (action.type) {
                                  case AUTH_USER:
                                      return {
                                          ...state,
                              Severity: Minor
                              Found in client/src/Redux/Reducers/authReducer.js - About 1 hr to fix

                                Function default has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export default function(ComposedComponent) {
                                    class AuthenticationForUser extends Component {
                                        static contextTypes = {
                                            router: React.PropTypes.object
                                        };
                                Severity: Minor
                                Found in client/src/Components/Auth/requireAuthUser.js - About 1 hr to fix

                                  Function checkRoleAndGetInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  exports.checkRoleAndGetInfo = async function (req, res) {
                                  
                                      try {
                                          const tokenContents = jwt.decode(req.body.token, config.secret);
                                          const role = tokenContents.role;
                                  Severity: Minor
                                  Found in server/controllers/authentication.js - About 1 hr to fix

                                    Function renderLinks has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        renderLinks() {
                                            if (this.props.auth !== "") {
                                                return [
                                                    <li className="nav-item" key={1}>
                                                        <Link className="nav-link" to="/account">
                                    Severity: Minor
                                    Found in client/src/Containers/Header/index.js - About 1 hr to fix

                                      Function renderLinks has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          renderLinks() {
                                              if (this.props.auth !== "") {
                                                  return [
                                                      <li className="nav-item" key={1}>
                                                          <Link className="nav-link" to="/account">
                                      Severity: Minor
                                      Found in client/src/Components/Header/index.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language