Showing 12 of 48 total issues
Function exports
has 170 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (server) => {
const inputValidations = require('./validations/input')
const outputValidations = require('./validations/output')
const fetchArticle = require('./routes_prerequisites').fetchArticle(server)
const fetchComment = require('./routes_prerequisites').fetchComment(server)
Function exports
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (server) => {
return {
/**
* GET /api/articles
*/
Function exports
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (server) => {
const replyHelper = require('../helpers')
function constructProfileResponse (user, authenticatedUser = null) {
let profile = { user: user.toProfileJSONFor(authenticatedUser) }
Function exports
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (server) => {
const handlers = require('./handlers')(server)
return [
// Get current user
{
Function exports
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (server) => {
function constructUserResponse (user) {
let authUser = { user: user.toAuthJSON() }
authUser.user.bio = user.bio || null
authUser.user.image = user.image || null
Function exports
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (server) => {
const handlers = require('./handlers')(server)
return [
// Get /profiles/{username}
{
Function getArticles
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getArticles (user, query, callback) {
let mQuery = {}
if (query.tag) {
mQuery.tagList = { $in: [ query.tag ] }
Function register
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const register = (server, options, next) => {
const preResponse = (request, reply) => {
let response = request.response
if (response.isBoom) {
const reformated = { errors: {} }
Function fetchArticle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const fetchArticle = server => {
return {
method: (request, reply) => {
if (!request.params.slug) {
return reply.continue()
- 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 fetchComment
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const fetchComment = server => {
return {
method: (request, reply) => {
if (!request.params.commentId) {
return reply.continue()
- 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 mongooseResponseValidationErrorHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function mongooseResponseValidationErrorHandler (err) {
if (err.name && err.name === 'ValidationError') {
let response = {
errors: {}
}
- 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 constructErrorResponse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const constructErrorResponse = (err) => {
var response
for (var handler in errorHandlers) {
let handlerFn = errorHandlers[handler]
if (typeof (handlerFn) === 'function') {
- 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"