| Total Complexity | 9 |
| Complexity/F | 3 |
| Lines of Code | 35 |
| Function Count | 3 |
| Duplicated Lines | 35 |
| Ratio | 100 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | /* |
||
| 6 | View Code Duplication | 'use strict' |
|
|
|
|||
| 7 | |||
| 8 | const minimatch = require('minimatch') |
||
| 9 | const Module = require('../containers/Module') |
||
| 10 | |||
| 11 | const matchFile = function (options, path) { |
||
| 12 | if (typeof options.paths === 'string') { |
||
| 13 | options.paths = [options.paths] |
||
| 14 | } |
||
| 15 | |||
| 16 | for (var i in options.paths) { |
||
| 17 | if (!options.paths.hasOwnProperty(i)) { |
||
| 18 | continue |
||
| 19 | } |
||
| 20 | if (minimatch(path, options.paths[i])) { |
||
| 21 | return true |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | return false |
||
| 26 | } |
||
| 27 | |||
| 28 | let manifest |
||
| 29 | Module.getManifest(function (manifestObj) { |
||
| 30 | manifest = manifestObj |
||
| 31 | }) |
||
| 32 | |||
| 33 | module.exports = function (path) { |
||
| 34 | var options = manifest.getDevOption('ignore') |
||
| 35 | if (!options || !('paths' in options)) { |
||
| 36 | return false |
||
| 37 | } |
||
| 38 | |||
| 39 | return matchFile(options, path) |
||
| 40 | } |
||
| 41 |