segunolalive/helloBooks

View on GitHub

Showing 33 of 36 total issues

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

  updateUser(req, res, next) {
    req.body = deleteEmptyFields(trimFields(req.body));
    delete req.body.id;
    delete req.body.isAdmin;
    delete req.body.username;
Severity: Minor
Found in server/middleware/validateInput.js - About 1 hr to fix

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

      signup(req, res, next) {
        req.body = deleteEmptyFields(trimFields(req.body));
        delete req.body.id;
        delete req.body.isAdmin;
        req.body.username = req.body.username && req.body.username.toLowerCase();
    Severity: Minor
    Found in server/middleware/validateInput.js - About 1 hr to fix

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

        updateUserInfo(req, res, next) {
          delete req.body.isAdmin;
          req.body.passwordResetToken = null;
          return User.findById(req.user.id)
            .then((user) => {
      Severity: Minor
      Found in server/controllers/UserController.js - About 1 hr to fix

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

          getBorrowedBooks(req, res, next) {
            const id = req.params.id;
            User.findOne({
              where: { id },
              include: [
        Severity: Minor
        Found in server/controllers/UserController.js - About 1 hr to fix

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

            up(queryInterface, Sequelize) {
              return queryInterface.createTable('Notifications', {
                id: {
                  allowNull: false,
                  autoIncrement: true,
          Severity: Minor
          Found in server/migrations/20170825171950-notifications.js - About 1 hr to fix

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

              up(queryInterface, Sequelize) {
                return queryInterface.createTable('BorrowedBooks', {
                  id: {
                    allowNull: false,
                    autoIncrement: true,
            Severity: Minor
            Found in server/migrations/20170821170955-BorrowedBook.js - About 1 hr to fix

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

              const authenticate = (req, res, next) => {
                const token = getToken(req);
                if (token) {
                  jwt.verify(token, process.env.SECRET, (error, decoded) => {
                    if (error) {
              Severity: Minor
              Found in server/middleware/authenticate.js - About 1 hr to fix

                Function render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  render() {
                    const actionButtons = this.props.isAdmin ? (
                      <div className="card-action">
                        <Button
                          className="teal darken-4 action-btn edit-btn"
                Severity: Minor
                Found in client/components/Library/BookDetail.jsx - About 55 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 BorrowedTable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                const BorrowedTable = (props) => {
                  const rows = props.books.length ? props.books.map((book) => {
                    const returned = book.borrowedBook.returned;
                    const bookImage = <img src={(book.cover &&
                      requestImageUrl(book.cover, { width: 50 })) || BOOK_IMAGE_FALLBACK}
                Severity: Minor
                Found in client/components/History/BorrowedTable.jsx - 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 validateSignUp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                export const validateSignUp = (state) => {
                  const errors = {};
                  if (state.username.charAt(0) === ' ') {
                    errors.username = 'Username cannot begin with space characters';
                  } else if (state.username.charAt(state.username.length - 1) === ' ') {
                Severity: Minor
                Found in client/utils/validation/auth.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 signup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  signup(req, res, next) {
                    req.body = deleteEmptyFields(trimFields(req.body));
                    delete req.body.id;
                    delete req.body.isAdmin;
                    req.body.username = req.body.username && req.body.username.toLowerCase();
                Severity: Minor
                Found in server/middleware/validateInput.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 res.status(400).send({
                        message: 'Passwords do not match'
                      });
                Severity: Major
                Found in server/middleware/validateInput.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return { ...state, books };
                  Severity: Major
                  Found in client/reducers/bookReducer.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language