prey/prey-node-client

View on GitHub
lib/agent/providers/network/windows.js

Summary

Maintainability
C
7 hrs
Test Coverage

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

exports.parse_access_points_list_netsh = (out) => {
  // eslint-disable-next-line prefer-const
  let list = [];
  const blocks = out.split(/\nSSID \d{1,2}\s:/);

Severity: Minor
Found in lib/agent/providers/network/windows.js - About 2 hrs to fix

    Function get_active_access_point has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.get_active_access_point = (callback) => {
      if (release >= 6.0) {
        // eslint-disable-next-line consistent-return
        exec('netsh wlan show interfaces', { timeout: 5000 }, (error, stdout) => {
          if (error) return callback(error);
    Severity: Minor
    Found in lib/agent/providers/network/windows.js - About 1 hr to fix

      Function get_access_points_list has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.get_access_points_list = (callback) => {
        let cmd;
        let parser;
        let list = [];
      
      
      Severity: Minor
      Found in lib/agent/providers/network/windows.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

      Function parse_access_points_list_netsh has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.parse_access_points_list_netsh = (out) => {
        // eslint-disable-next-line prefer-const
        let list = [];
        const blocks = out.split(/\nSSID \d{1,2}\s:/);
      
      
      Severity: Minor
      Found in lib/agent/providers/network/windows.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

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

      exports.get_access_points_list = (callback) => {
        let cmd;
        let parser;
        let list = [];
      
      
      Severity: Minor
      Found in lib/agent/providers/network/windows.js - About 1 hr to fix

        Function get_active_access_point_mac has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.get_active_access_point_mac = (callback) => {
          if (release >= 6.0) {
            // eslint-disable-next-line consistent-return
            exec('netsh wlan show interfaces', (err, stdout) => {
              if (err) return callback(err);
        Severity: Minor
        Found in lib/agent/providers/network/windows.js - About 55 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

        There are no issues that match your filters.

        Category
        Status