index.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.2

Size

Lines of Code 26
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
wmc 6
c 2
b 0
f 0
nc 1
mnd 1
bc 6
fnc 5
dl 0
loc 26
rs 10
bpm 1.2
cpm 1.2
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A ➔ ??? 0 13 1
1
'use strict'
2
3
const path = require('path')
4
5
const render = (options, res, next) => {
0 ignored issues
show
Unused Code introduced by
The parameter next is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
6
  const callback = (err, html) => {
7
    if (err) {
8
      throw err
9
    }
10
    res.setHeader('Content-Type', 'text/html')
11
    res.writeHead(200)
12
    res.end(html)
13
  }
14
  return function (view, state = {}, userCallback) {
15
    options.engine(path.join(options.dir, view), state, userCallback || callback)
16
  }
17
}
18
19
const middleware = (options) => {
20
  return function (req, res, next) {
21
    res.render = render(options, res, next)
22
    next()
23
  }
24
}
25
26
module.exports = middleware
27