CodeTheChangeUBC/sasc

View on GitHub

Showing 49 of 160 total issues

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

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

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

        render() {
            return (
                <div className="message-box" id="message-box">
                    {this.props.msgs.map(
                        ({
    Severity: Minor
    Found in client/src/Components/Chat/MessageBox.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

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

        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

          Function process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.process = function(values) {
              return new Promise(function(resolve, reject) {
                  if (values.password) {
                      bcrypt.hash(values.password, SALT_ROUNDS, function(err, hash) {
                          if (err) {
          Severity: Minor
          Found in server/models/abstract.js - About 45 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

          Function abstractSignup has a Cognitive Complexity of 8 (exceeds 5 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 45 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

          Function updateAccount has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          exports.updateAccount = async function (role, model, user, id, req, res) {
          Severity: Minor
          Found in server/controllers/account.js - About 45 mins to fix

            Function changePassword has a Cognitive Complexity of 8 (exceeds 5 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 45 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

            Function abstractSignup has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            async function abstractSignup(user, requiredCredentials, role, res, model) {
            Severity: Minor
            Found in server/controllers/authentication.js - About 35 mins to fix

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

              async function abstractJwtLogin(payload, done, role, model) {
                  // lookup user by user id from payload subject
                  // and return the user object if found
                  // or false if not found
                  var err, users;
              Severity: Minor
              Found in server/services/passport.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

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

              function fieldQueries(fields, and) {
                  var query = '';
                  for (var j=0; j<fields.length; j++) {
                      query += ' '+fields[j]+'=?';
                      if (j!=fields.length-1) {
              Severity: Minor
              Found in server/models/abstract.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

              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

                Avoid too many return statements within this function.
                Open

                    return res.status(201).send({
                        success: "Survey successfully submitted.",
                        userid: results.insertId
                    });
                Severity: Major
                Found in server/controllers/user.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return res.status(201).send({success: "Successfully changed password."});
                  Severity: Major
                  Found in server/controllers/account.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return res.status(422).send({error: "Failed to change password."});
                    Severity: Major
                    Found in server/controllers/account.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return res.status(201).send({success: "Successfully added or updated twilio account information."});
                      Severity: Major
                      Found in server/controllers/twilio.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return res.status(422).send({error: "Failed to encrypt password."});
                        Severity: Major
                        Found in server/controllers/account.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return res.status(422).send({error: "Database "+role+" update error."});
                          Severity: Major
                          Found in server/controllers/account.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return res.status(422).send({error: "Failed to encrypt password."});
                            Severity: Major
                            Found in server/controllers/account.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return res.status(422).send({error: "Failed to change password."});
                              Severity: Major
                              Found in server/controllers/account.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language