senecajs/seneca

View on GitHub

Showing 177 of 189 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function action_client(msg, reply) {
    const seneca = this;
    const config = Object.assign({}, msg.config, {
        role: 'transport',
        hook: 'client',
Severity: Major
Found in lib/transport.js and 1 other location - About 2 hrs to fix
lib/transport.js on lines 169..178

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 89.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function action_client(this: any, msg: any, reply: any) {
  const seneca = this

  const config = Object.assign({}, msg.config, {
    role: 'transport',
Severity: Major
Found in lib/transport.ts and 1 other location - About 2 hrs to fix
lib/transport.ts on lines 207..220

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 89.

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

Further Reading

Function build_log_spec has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function build_log_spec(self: any) {
  var options = self.options()
  var orig_logspec: any = options.log

  // Canonize logspec into a standard object structure
Severity: Minor
Found in lib/logging.ts - About 2 hrs 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 build_log_spec has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function build_log_spec(self) {
    var options = self.options();
    var orig_logspec = options.log;
    // Canonize logspec into a standard object structure
    var logspec = Common.deep({ text_level: {} }, default_logspec, orig_logspec && 'object' === typeof orig_logspec ? orig_logspec : {});
Severity: Minor
Found in lib/logging.js - About 2 hrs 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 make_use has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function make_use(ordu: any, callpoint: any) {
  let seq = { index: 0 }

  return function use(this: any) {
    let self = this
Severity: Minor
Found in lib/plugin.ts - About 2 hrs 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 act_error has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

intern.act_error = function(instance: any, ctx: any, data: any) {
  var duration = ctx.duration
  var act_callpoint = ctx.callpoint
  var actdef = ctx.actdef || {}
  var origmsg = ctx.origmsg
Severity: Minor
Found in lib/outward.ts - About 2 hrs 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 act_error has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

intern.act_error = function (instance, ctx, data) {
    var duration = ctx.duration;
    var act_callpoint = ctx.callpoint;
    var actdef = ctx.actdef || {};
    var origmsg = ctx.origmsg;
Severity: Minor
Found in lib/outward.js - About 2 hrs 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 make_use has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function make_use(ordu, callpoint) {
    let seq = { index: 0 };
    return function use() {
        let self = this;
        let args = [...arguments];
Severity: Minor
Found in lib/plugin.js - About 2 hrs 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 make_plugin_key has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function make_plugin_key(plugin: any, origtag: any) {
  if (null == plugin) {
    throw error('missing_plugin_name')
  }

Severity: Minor
Found in lib/common.ts - About 2 hrs 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 client has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function client(this: any, callpoint: any) {
  return function api_client(this: any) {
    const private$ = this.private$
    const argsarr = Array.prototype.slice.call(arguments)
    const self = this
Severity: Minor
Found in lib/api.ts - About 2 hrs 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 client has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function client(callpoint) {
    return function api_client() {
        const private$ = this.private$;
        const argsarr = Array.prototype.slice.call(arguments);
        const self = this;
Severity: Minor
Found in lib/api.js - About 2 hrs 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 make_plugin_key has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function make_plugin_key(plugin, origtag) {
    if (null == plugin) {
        throw error('missing_plugin_name');
    }
    let name = null == plugin.name ? plugin : plugin.name;
Severity: Minor
Found in lib/common.js - About 2 hrs 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 make_intern has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function make_intern() {
  return {
    // TODO: explicit tests for these operators

    op: {
Severity: Minor
Found in lib/plugin.ts - About 2 hrs 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 make_intern has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function make_intern() {
    return {
        // TODO: explicit tests for these operators
        op: {
            seneca_plugin: (tr, ctx, data) => {
Severity: Minor
Found in lib/plugin.js - About 2 hrs 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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function translate(from_in, to_in, pick_in, flags) {
    const from = 'string' === typeof from_in ? this.util.Jsonic(from_in) : from_in;
    const to = 'string' === typeof to_in ? this.util.Jsonic(to_in) : to_in;
    let pick = {};
    if ('string' === typeof pick_in) {
Severity: Minor
Found in lib/api.js - About 2 hrs 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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function translate(
  this: any,
  from_in: any,
  to_in: any,
  pick_in?: any,
Severity: Minor
Found in lib/api.ts - About 2 hrs 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 do_act has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    do_act: function (instance, opts, origmsg, origreply) {
        let timedout = false;
        const actmsg = intern.make_actmsg(origmsg);
        const meta = new meta_1.Meta(instance, opts, origmsg, origreply);
        // Gated actions must complete before further actions can start.
Severity: Minor
Found in lib/act.js - About 2 hrs 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 do_act has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  do_act: function(instance: any, opts: any, origmsg: any, origreply: any) {
    let timedout = false
    const actmsg = intern.make_actmsg(origmsg)
    const meta = new Meta(instance, opts, origmsg, origreply)

Severity: Minor
Found in lib/act.ts - About 2 hrs 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 inward_validate_msg has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function inward_validate_msg(spec: any) {
  const ctx = spec.ctx
  const data = spec.data

  var so = ctx.options
Severity: Minor
Found in lib/inward.ts - 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 inward_validate_msg has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function inward_validate_msg(spec) {
    const ctx = spec.ctx;
    const data = spec.data;
    var so = ctx.options;
    var msg = data.msg;
Severity: Minor
Found in lib/inward.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

Severity
Category
Status
Source
Language