Showing 10 of 11 total issues
Function loanBook
has 130 lines of code (exceeds 60 allowed). Consider refactoring. Open
Open
loanBook(req, res) {
const userId = req.user.id.id || req.user.id;
const { bookId } = req.body;
if (!req.body.returnDate) {
return res
File books.js
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import models from '../models';
import pagination from '../controllers/helpers/pagination';
const { Categories, Books, UserBooks } = models;
File user.js
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import bcrypt from 'bcrypt';
import models from '../models';
import generateToken from '../controllers/middleware/authenticate';
import pagination from '../controllers/helpers/pagination';
Function render
has 89 lines of code (exceeds 60 allowed). Consider refactoring. Open
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
Open
returnBook(req, res) {
const userId = req.user.id.id || req.user.id;
const bookId = req.body.bookId;
UserBooks.findOne({
where: {
Function BorrowHistoryTable
has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring. Open
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">
- Read upRead up
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
Open
addBook(req, res) {
Categories
.findOne({
where: {
id: req.body.categoryId
Function render
has 65 lines of code (exceeds 60 allowed). Consider refactoring. Open
Open
render() {
if (!this.props.allBooksList.books) {
return <Preloader size="big"/>;
}
this.props.fetchAllBorrowedBooks(
Function render
has 61 lines of code (exceeds 60 allowed). Consider refactoring. Open
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
Open
const validateSignUpInput = (state) => {
const errors = {};
if (!validateEmail(state.email)) {
errors.email = 'Email is Invalid';
}
- Read upRead up
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"