laundree/laundree

View on GitHub

Showing 37 of 96 total issues

Function linkEmitter has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

export function linkEmitter<A, B> (subEmitter: EventEmitter, pubEmitter: EventEmitter, name: string, listen: string[], serialize: (a: A) => Promise<string>, deserialize: (s: string) => Promise<B>) {
Severity: Minor
Found in src/db/redis.js - About 45 mins to fix

Function createInitialStore has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

export async function createInitialStore (currentUser: ?User, successFlash: string[] = [], errorFlash: string[] = [], locale: LocaleType = 'en', token: string = '', statistics: {userCount: number, bookingCount: number}) {
Severity: Minor
Found in src/web/redux.js - About 45 mins to fix

Function findTokenFromSecret has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async findTokenFromSecret (secret: string, filter: QueryConditions) {
    switch (secret.substring(0, 2)) {
      case 'v2':
        const [, id, sec] = secret.split('.')
        const [token] = await this.find({$and: [{_id: id}, filter]})
Severity: Minor
Found in src/handlers/token.js - About 35 mins to fix

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

  if (day === null) return null
Severity: Major
Found in src/websocket/socket_io.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return true
Severity: Major
Found in src/react/validation/ValidationElement.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      if (props.nonEmpty) return Boolean(value)
Severity: Major
Found in src/react/validation/ValidationElement.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      if (props.oneOf) return props.oneOf.indexOf(value) >= 0
Severity: Major
Found in src/react/validation/ValidationElement.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      if (props.email) return regex.email.exec(value)
Severity: Major
Found in src/react/validation/ValidationElement.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return tok.verify(token)
Severity: Major
Found in src/handlers/user.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return {day, year, month}
Severity: Major
Found in src/websocket/socket_io.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      if (props.password) return regex.password.exec(value)
Severity: Major
Found in src/react/validation/ValidationElement.js - About 30 mins to fix

Function constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  constructor () {
    super(MachineHandler, MachineModel, {
      create: obj => typeof obj === 'string' ? null : {type: 'CREATE_MACHINE', payload: obj.reduxModel()},
      update: obj => typeof obj === 'string' ? null : {type: 'UPDATE_MACHINE', payload: obj.reduxModel()},
      delete: obj => typeof obj !== 'string' ? null : {type: 'DELETE_MACHINE', payload: obj}
Severity: Minor
Found in src/handlers/machine.js - About 25 mins to fix

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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  constructor () {
    super(LaundryInvitationHandler, LaundryInvitationModel, {
      create: obj => typeof obj === 'string' ? null : {type: 'CREATE_INVITATION', payload: obj.reduxModel()},
      update: obj => typeof obj === 'string' ? null : {type: 'UPDATE_INVITATION', payload: obj.reduxModel()},
      delete: obj => typeof obj !== 'string' ? null : {type: 'DELETE_INVITATION', payload: obj}
Severity: Minor
Found in src/handlers/laundry_invitation.js - About 25 mins to fix

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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  constructor () {
    super(LaundryHandler, LaundryModel, {
      create: obj => typeof obj === 'string' ? null : {type: 'CREATE_LAUNDRY', payload: obj.reduxModel()},
      update: obj => typeof obj === 'string' ? null : {type: 'UPDATE_LAUNDRY', payload: obj.reduxModel()},
      delete: obj => typeof obj !== 'string' ? null : {type: 'DELETE_LAUNDRY', payload: obj}
Severity: Minor
Found in src/handlers/laundry.js - About 25 mins to fix

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 _findAdjacentBookings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async _findAdjacentBookings (user: UserHandler, from: Date, to: Date) {
    const [{before, after}, laundry] = await (
      Promise.all([
        this.findAdjacentBookingsOfUser(user, from, to), // Find bookings that should be merged
        this.fetchLaundry()
Severity: Minor
Found in src/handlers/machine.js - About 25 mins to fix

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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  constructor () {
    super(BookingHandler, BookingModel, {
      create: obj => typeof obj === 'string' ? null : ({type: 'CREATE_BOOKING', payload: obj.reduxModel()}),
      update: obj => typeof obj === 'string' ? null : ({type: 'UPDATE_BOOKING', payload: obj.reduxModel()}),
      delete: obj => typeof obj !== 'string' ? null : ({type: 'DELETE_BOOKING', payload: obj})
Severity: Minor
Found in src/handlers/booking.js - About 25 mins to fix

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 handleError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function handleError (res: Response, err: Error) {
  const status = (typeof err.status === 'number' && err.status) ||
    (res.statusCode >= 400 && res.statusCode) ||
    500
  res.status(status)
Severity: Minor
Found in src/api/helper.js - About 25 mins to fix

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

Severity
Category
Status
Source
Language