prey/prey-node-client

View on GitHub
lib/agent/actions/wipe/index.js

Summary

Maintainability
C
1 day
Test Coverage

Function start has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.start = (id, options, cb) => {
  const opts = options || {};
  const token = opts.token || null;
  // const confirm = opts.confirm === 'ireallyknowwhatiamdoing';
  const items = validTypes(opts);
Severity: Major
Found in lib/agent/actions/wipe/index.js - About 4 hrs to fix

    Function spawn has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const spawn = () => {
        const wipeOpts = [
          '-token', opts.token,
          cloud.toString(),
          directories.toString(),
    Severity: Major
    Found in lib/agent/actions/wipe/index.js - About 2 hrs to fix

      Function start has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.start = (id, options, cb) => {
        const opts = options || {};
        const token = opts.token || null;
        // const confirm = opts.confirm === 'ireallyknowwhatiamdoing';
        const items = validTypes(opts);
      Severity: Minor
      Found in lib/agent/actions/wipe/index.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

      Consider simplifying this complex logical expression.
      Open

          if ((val !== 'false' && val !== 'off' && key.includes('wipe_')) && (val === 'on' || val === 'true' || validDirs(val))) {
            const method = key.replace('wipe_', ''); // just 'cookies'
            if (typeof wipe[method] === 'function') list.push(method);
          }
      Severity: Major
      Found in lib/agent/actions/wipe/index.js - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status