Showing 67 of 142 total issues
Function deleteComment
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async deleteComment(req, res) {
const userId = req.auth.id;
const getUser = await CommentsDb.findOne({ where: { userId } });
const commentAuthor = getUser && getUser.get().userId;
const { id } = req.params;
Function validateToken
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const validateToken = async (req, res, next) => {
let token = req.headers['x-access-token'] || req.headers.authorization;
if (!token) {
return res.status(401).send({
status: 401,
- 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 checkQuery
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const checkQuery = (req, res, next) => {
let {
limit, page, popular, ...searchQueries
} = req.query;
const validQueries = ['author', 'keyword', 'tag', 'title'];
- 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 bodyHighlightedText
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async bodyHighlightedText(req, res) {
try {
const [{ id: userId }, { slug }, { startIndex, endIndex }] = [req.auth, req.params, req.query];
const start = Number(startIndex);
const end = Number(endIndex);
- 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(200).send({
status: 200,
message: 'Password reset successfully'
});
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return res.status(500).send({
status: 500,
message: error.message
});
Avoid too many return
statements within this function. Open
return res.send({
message: error.message
});
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return res.status(404).send({
status: 404,
message: errors[0].message
});
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return res.status(400).send({
status: 400,
message: 'Failed to fetch user'
});
Avoid too many return
statements within this function. Open
return util.send(res);
Avoid too many return
statements within this function. Open
return res.status(404).send({
status: 404,
message: error
});
Avoid too many return
statements within this function. Open
return util.send(res);