hairyhenderson/f1foo

View on GitHub

Showing 6 of 6 total issues

Function createPersonRecord has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

F1Register.prototype.createPersonRecord = function (reg, callback) {
  this.getStatus(NEW_STATUS, function (err, status) {
    if (err) return callback(err)

    this.createHousehold(reg, function (err, householdResponse) {
Severity: Minor
Found in lib/F1Register.js - About 1 hr 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 translate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

WufooTranslator.prototype.translate = function (postBody, callback) {
  process.nextTick(function () {
    if (validBody(postBody)) {
      debug('translating %j', postBody)
      var struct = JSON.parse(postBody.FieldStructure)
Severity: Minor
Found in lib/WufooTranslator.js - About 1 hr to fix

Function handler has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

Hooks.prototype.handler = function (req, res, next) {
  this.validateBody(req.body, function valid (err) {
    if (typeof (err) === 'string') return res.status(400).send(err)
    if (typeof (err) === 'number') return res.status(err).end()

Severity: Minor
Found in routes/hooks.js - About 1 hr 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 _createComm has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

F1Register.prototype._createComm = function (generalCommName, commName, person, reg, callback) {
Severity: Minor
Found in lib/F1Register.js - About 35 mins to fix

Avoid too many return statements within this function.
Open

    return callback()
Severity: Major
Found in routes/hooks.js - About 30 mins to fix

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

Hooks.prototype.validateBody = function (body, callback) {
  if (!body) {
    debug('missing body (%j)', body)
    return callback('missing body')
  } else if (!body.FieldStructure) {
Severity: Minor
Found in routes/hooks.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