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;
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();
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) => {
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: [
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,
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,
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) {
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"
- 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 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}
- 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 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) === ' ') {
- 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 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();
- 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
Avoid too many return
statements within this function. Open
return res.status(400).send({
message: 'Passwords do not match'
});
Avoid too many return
statements within this function. Open
return { ...state, books };