laundree/laundree

View on GitHub

Showing 96 of 96 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  constructor (model: LaundryInvitationModel) {
    super(model)
    this.href = restUrlPrefix + this.model.id
  }
Severity: Minor
Found in src/handlers/laundry_invitation.js and 1 other location - About 30 mins to fix
src/handlers/booking.js on lines 125..128

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  constructor (model: BookingModel) {
    super(model)
    this.restUrl = restUrlPrefix + this.model.id
  }
Severity: Minor
Found in src/handlers/booking.js and 1 other location - About 30 mins to fix
src/handlers/laundry_invitation.js on lines 45..48

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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