steve-jansen/json-proxy

View on GitHub

Showing 9 of 21 total issues

Function optimist has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function optimist() {
  var usage = [
    pkginfo.name + ' v' + pkginfo.version,
    '',
    'A utility for UI developers to proxy JSON API calls to remote servers',
Severity: Minor
Found in lib/cli.js - About 2 hrs to fix

Function parseCommandLine has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function parseCommandLine(argv, config) {
  if (argv) {
    // read the command line arguments if no config file was given
    parseCommandLineArgument(argv.port, function(item){
      config.server.port = item;
Severity: Minor
Found in lib/config.js - About 1 hr to fix

Function proxyRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function proxyRequest(req, res, rule) {
  var router,
      target,
      path;

Severity: Minor
Found in lib/proxy.js - About 1 hr to fix

Function parseFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function parseFile(filepath, config) {
  var contents;

  filepath = filepath || path.join(process.cwd(), '/json-proxy.json');

Severity: Minor
Found in lib/config.js - About 35 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 parseEnv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function parseEnv(config) {
  var env = process.env;
  var temp;

  if (env['JSON_PROXY_PORT']) {
Severity: Minor
Found in lib/config.js - About 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

exports.initialize = function initialize(options){
  logger = options.logger || require('./logger');
  config = configParser(options).proxy;
  useGateway = (config.gateway !== null && typeof(config.gateway) === 'object' && typeof(config.gateway.host) === 'string');

Severity: Minor
Found in lib/proxy.js - About 35 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 parseTargetServer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function parseTargetServer(value) {
  var target,
      path;

  // insert a http protocol handler if not found in the string
Severity: Minor
Found in lib/config.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 parseCommandLineArgument has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function parseCommandLineArgument(arg, fn) {
  if (typeof(fn) !== 'function')
    return;

  if (Array.isArray(arg)) {
Severity: Minor
Found in lib/config.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 proxyRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function proxyRequest(req, res, rule) {
  var router,
      target,
      path;

Severity: Minor
Found in lib/proxy.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