benfluleck/HelloBooks

View on GitHub

Showing 10 of 11 total issues

Function loanBook has 130 lines of code (exceeds 60 allowed). Consider refactoring.
Open

  loanBook(req, res) {
    const userId = req.user.id.id || req.user.id;
    const { bookId } = req.body;
    if (!req.body.returnDate) {
      return res
Severity: Major
Found in server/src/controllers/userBooks.js - About 3 hrs to fix

    File books.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import models from '../models';
    import pagination from '../controllers/helpers/pagination';
    
    const { Categories, Books, UserBooks } = models;
    
    
    Severity: Minor
    Found in server/src/controllers/books.js - About 3 hrs to fix

      File user.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import bcrypt from 'bcrypt';
      import models from '../models';
      import generateToken from '../controllers/middleware/authenticate';
      import pagination from '../controllers/helpers/pagination';
      
      
      Severity: Minor
      Found in server/src/controllers/user.js - About 2 hrs to fix

        Function render has 89 lines of code (exceeds 60 allowed). Consider refactoring.
        Open

          render() {
            const {
              title, author, quantity, description, bookImage, imageName, categoryId
            } = this.props.book;
        
        

          Function returnBook has 86 lines of code (exceeds 60 allowed). Consider refactoring.
          Open

            returnBook(req, res) {
              const userId = req.user.id.id || req.user.id;
              const bookId = req.body.bookId;
              UserBooks.findOne({
                where: {
          Severity: Major
          Found in server/src/controllers/userBooks.js - About 2 hrs to fix

            Function BorrowHistoryTable has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
            Open

            const BorrowHistoryTable = (props) => {
              const rows = props.books && props.books.length ?
                props.books.map((book, index) => (
                  <tr key={index}>
                    <td className="book-cover-on-table">

            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 addBook has 65 lines of code (exceeds 60 allowed). Consider refactoring.
            Open

              addBook(req, res) {
                Categories
                  .findOne({
                    where: {
                      id: req.body.categoryId
            Severity: Major
            Found in server/src/controllers/books.js - About 1 hr to fix

              Function render has 65 lines of code (exceeds 60 allowed). Consider refactoring.
              Open

                render() {
                  if (!this.props.allBooksList.books) {
                    return <Preloader size="big"/>;
                  }
                  this.props.fetchAllBorrowedBooks(
              Severity: Major
              Found in client/src/app/components/container/booklist/DisplayAllBooks.jsx - About 1 hr to fix

                Function render has 61 lines of code (exceeds 60 allowed). Consider refactoring.
                Open

                  render() {
                    if (!this.props.userLevels) {
                      return (<Preloader size="big" className="center-align" />);
                    }
                    const userLevelNames = this.props.userLevels

                  Function validateSignUpInput has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
                  Open

                  const validateSignUpInput = (state) => {
                    const errors = {};
                    if (!validateEmail(state.email)) {
                      errors.email = 'Email is Invalid';
                    }
                  Severity: Minor
                  Found in client/src/app/validators/validator.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

                  Severity
                  Category
                  Status
                  Source
                  Language