Showing 386 of 386 total issues
Function create
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create (logger, encoding, isEndOfRequest) {
if (typeof isEndOfRequest === 'undefined') {
isEndOfRequest = () => true; // defaults to a packet boundary
}
Function create
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create () {
const imposters = {},
stubRepos = {};
/**
Function wrap
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wrap (stub) {
const cloned = helpers.clone(stub || {}),
stubDir = stub ? stub.meta.dir : '';
if (typeof stub === 'undefined') {
Function create
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create (releases) {
const feedReleases = helpers.clone(releases);
// Init once since we hope many consumers poll the heroku feed and we don't have monitoring
feedReleases.reverse();
Function predicatesFor
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function predicatesFor (request, matchers, logger) {
const predicates = [];
matchers.forEach(matcher => {
if (matcher.inject) {
Function useAbsoluteUrls
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useAbsoluteUrls (port) {
return function (request, response, next) {
const setHeaderOriginal = response.setHeader,
sendOriginal = response.send,
host = request.headers.host || `localhost:${port}`,
Function to
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function to (proxyDestination, originalRequest, options = {}) {
return new Promise((resolve, reject) => {
try {
const proxyName = socketName(connectionInfoFor(proxyDestination)),
log = (direction, what) => {
Similar blocks of code found in 2 locations. Consider refactoring. Open
argv = yargs
.usage('Usage: mb [command=start] [options...]')
.command('start', 'Starts the server (default command)', startYargs => {
startYargs
.usage('Usage: mb [start] [options...]')
- Read upRead up
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 71.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function listen
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function listen (app, options) {
const hostname = options.host || 'localhost',
baseURL = `http://${hostname}:${options.port}`,
logger = utilLogger.createLogger(options),
isAllowedConnection = utilIp.createIPVerification(options);
Identical blocks of code found in 2 locations. Consider refactoring. Open
const imposter = await imposters.get(request.params.id),
stubs = imposters.stubsFor(request.params.id),
validation = await validateStubIndex(stubs, request.params.stubIndex);
- Read upRead up
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 66.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
const imposter = await imposters.get(request.params.id),
stubs = imposters.stubsFor(request.params.id),
validation = await validateStubIndex(stubs, request.params.stubIndex);
- Read upRead up
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 66.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function send
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
response.send = function () {
const args = Array.prototype.slice.call(arguments),
body = args[0],
changeLinks = function (obj) {
if (obj._links) {
Function createStubsRepository
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function createStubsRepository () {
const stubs = [];
let requests = [];
function reindex () {
- Read upRead up
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 postProcess
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function postProcess (stubResponse, request) {
/* eslint complexity: 0 */
const defaultHeaders = defaultResponse.headers || {},
response = {
statusCode: stubResponse.statusCode || defaultResponse.statusCode || 200,
Function curl
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function curl (options, method, path, body) {
return new Promise((resolve, reject) => {
const requestOptions = {
method: method,
path: path,
Function selectRowFromCSV
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function selectRowFromCSV (csvConfig, keyValue, logger) {
const delimiter = csvConfig.delimiter || ',',
inputStream = fsExtra.createReadStream(csvConfig.path),
parser = csvParse.parse({ delimiter: delimiter }),
pipe = inputStream.pipe(parser);
Function parseLogConfiguration
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseLogConfiguration (args) {
// Not defaulted in yargs so we can test yargs value without defaulting interfering.
// This is needed for backwards compatibility with older CLI options.
const defaultConfig = {
level: 'info',
Identical blocks of code found in 2 locations. Consider refactoring. Open
close: callback => {
server.close(callback);
Object.keys(connections).forEach(socket => {
connections[socket].destroy();
});
- Read upRead up
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 61.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
close: callback => {
server.close(callback);
Object.keys(connections).forEach(socket => {
connections[socket].destroy();
});
- Read upRead up
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 61.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function predicateSatisfied
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function predicateSatisfied (expected, actual, predicateConfig, predicateFn) {
if (!actual) {
return false;
}