Showing 37 of 96 total issues
File user.js
has 411 lines of code (exceeds 250 allowed). Consider refactoring. Open
// @flow
import { Handler, HandlerLibrary } from './handler'
import TokenHandler from './token'
import BookingHandler from './booking'
- Create a ticketCreate a ticket
UserHandler
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
export default class UserHandler extends Handler<UserModel, User, RestUser> {
static lib = new UserHandlerLibrary()
lib = UserHandler.lib
static restSummary (i: ObjectId | UserHandler) {
- Create a ticketCreate a ticket
LaundryHandler
has 39 functions (exceeds 20 allowed). Consider refactoring. Open
export default class LaundryHandler extends Handler<LaundryModel, ReduxLaundry, RestLaundry> {
static restSummary (i: ObjectId | LaundryHandler) {
const id = Handler.handlerOrObjectIdToString(i)
return {id, href: restUrlPrefix + id}
}
- Create a ticketCreate a ticket
File socket_io.js
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
// @flow
import connectMongoose from '../db/mongoose'
import socketIo from 'socket.io'
import UserHandler from '../handlers/user'
import LaundryHandler from '../handlers/laundry'
- Create a ticketCreate a ticket
File laundry.js
has 356 lines of code (exceeds 250 allowed). Consider refactoring. Open
// @flow
import LaundryModel from '../db/models/laundry'
import type { LaundryRules } from '../db/models/laundry'
import { Handler, HandlerLibrary } from './handler'
import UserHandler from './user'
- Create a ticketCreate a ticket
Function setupAdminFunctions
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupAdminFunctions (socket) {
debug('Adding admin functions')
defineSocketFunction(
socket,
'listLaundries',
- Create a ticketCreate a ticket
Function validate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
validate (props: ValidationElementProps<V> = this.props): boolean {
const value = props.trim && typeof props.value === 'string'
? props.value.trim()
: props.value
if (props.equal !== undefined) return props.equal === value
- Read upRead up
- Create a ticketCreate a ticket
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 setupFunctions
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupFunctions (socket) {
defineLaundrySocketFunction(
socket,
'listBookingsInTime',
async (laundry, fromO, toO) => {
- Create a ticketCreate a ticket
Function createBookingAsync
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function createBookingAsync (subjects, params) {
const {machine, laundry, currentUser, createBookingBody} = api
.assertSubjects({
machine: subjects.machine,
currentUser: subjects.currentUser,
- Create a ticketCreate a ticket
Function setupUser
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupUser (socket, userUpdateEmitter, u: ?UserHandler) {
const user = u
if (!user) {
debug('Found no user, will not setup')
return
- Create a ticketCreate a ticket
Function createInvitePdf
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function createInvitePdf (laundryId: string, code: string, locale: LocaleType) {
const doc = new PdfDocument({size: [2 * 240, 2 * 320]})
const link = `https://laundree.io/s/${laundryId}/${code}`
const logoWidth = 150
const logoX = (doc.page.width - logoWidth) / 2
- Create a ticketCreate a ticket
Function updateBookingAsync
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updateBookingAsync (subjects, params) {
const {booking, laundry, currentUser, updateBookingBody} = api
.assertSubjects({
booking: subjects.booking,
currentUser: subjects.currentUser,
- Create a ticketCreate a ticket
Function authenticateSocket
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function authenticateSocket (socket): Promise<?UserHandler> {
debug('Authenticating user')
const {userId, token, jwt} = socket.handshake.query || {} // Authenticate token from query
if (userId && token) {
debug('Got userId and token', userId, token)
- Read upRead up
- Create a ticketCreate a ticket
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 createBookingAsync
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function createBookingAsync (subjects, params) {
const {machine, laundry, currentUser, createBookingBody} = api
.assertSubjects({
machine: subjects.machine,
currentUser: subjects.currentUser,
- Read upRead up
- Create a ticketCreate a ticket
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 authenticateSocket
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function authenticateSocket (socket): Promise<?UserHandler> {
debug('Authenticating user')
const {userId, token, jwt} = socket.handshake.query || {} // Authenticate token from query
if (userId && token) {
debug('Got userId and token', userId, token)
- Create a ticketCreate a ticket
Function basic
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function basic (req, authOrSecDef, scopesOrApiKey, callback) {
const authHeader = req.header('authorization')
const match = authHeader && authHeader.match(/^Basic (.+)$/)
const token = match && match[1]
debug('Verifying token %s', token)
- Create a ticketCreate a ticket
Function pullSubjects
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async function pullSubjects (params: ParsedParams, req: Request): Promise<Subjects> {
const currentUserId = req.userId || null
const currentUser = await (currentUserId && UserHandler.lib.findFromId(currentUserId))
const [user, machine, token, invite, laundry, booking] = await Promise.all([
params.userId ? pullSubject(params.userId, UserHandler) : null,
- Read upRead up
- Create a ticketCreate a ticket
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 inviteUserByEmailAsync
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function inviteUserByEmailAsync (subs, params) {
const {laundry, inviteUserByEmailBody} = api.assertSubjects({
laundry: subs.laundry,
inviteUserByEmailBody: params.inviteUserByEmailBody
})
- Create a ticketCreate a ticket
Function createInitialEvents
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function createInitialEvents (currentUser: ?User, successFlash: string[] = [], errorFlash: string[] = [], locale: LocaleType = 'en', token: string = '', statistics: {userCount: number, bookingCount: number}) {
- Create a ticketCreate a ticket
Function updateBookingAsync
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function updateBookingAsync (subjects, params) {
const {booking, laundry, currentUser, updateBookingBody} = api
.assertSubjects({
booking: subjects.booking,
currentUser: subjects.currentUser,
- Read upRead up
- Create a ticketCreate a ticket
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"