prey/prey-node-client

View on GitHub

Showing 524 of 524 total issues

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

  def validate_new_user_fields(self):
    if self.text('user_name') == '':
      self.show_alert(_("Empty name!"), _("Please type in your name."))
      return False
    if self.text('email') == '':
Severity: Major
Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 2 days to fix
lib/conf/gui/linux/prey-config3.py on lines 109..137

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

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

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

    def validate_new_user_fields(self):
        if self.text("user_name") == "":
            self.show_alert(_("Empty name!"), _("Please type in your name."))
            return False
        if self.text("email") == "":
Severity: Major
Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 2 days to fix
lib/conf/gui/linux/prey-config.py on lines 103..122

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

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

  def __init__(self):
    if not FORCE_CONFIG and self.client_configured():
      return self.exit_ok()

    builder = gtk.Builder()
Severity: Major
Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 1 day to fix
lib/conf/gui/linux/prey-config3.py on lines 377..406

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

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

    def __init__(self):
        if not FORCE_CONFIG and self.client_configured():
            return self.exit_ok()

        builder = Gtk.Builder()
Severity: Major
Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 1 day to fix
lib/conf/gui/linux/prey-config.py on lines 337..364

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

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

File index.js has 657 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var schedule = require('node-schedule');
var EventEmitter = require('events').EventEmitter;
var logger = require('./../../common').logger.prefix('triggers');
Severity: Major
Found in lib/agent/actions/triggers/index.js - About 1 day to fix

    Function track_hardware_changes has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

    exp.track_hardware_changes = (dataTrack) => {
      const data = dataTrack;
      if (data.tpm_module) delete data.tpm_module;
      if (data.os_edition) delete data.os_edition;
      if (data.winsvc_version) delete data.winsvc_version;
    Severity: Minor
    Found in lib/agent/providers/hardware/index.js - About 1 day 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

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

      def set_default_action(self,button,ctrl):
        button_cancel = self.get('button_cancel')
        cancel_has_default = button_cancel.flags() & gtk.HAS_DEFAULT
        button_prev = self.get('button_prev')
        prev_has_default = button_prev.flags() & gtk.HAS_DEFAULT
    Severity: Major
    Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 1 day to fix
    lib/conf/gui/linux/prey-config3.py on lines 236..248

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

    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

        def set_default_action(self, button, ctrl):
            button_cancel = self.get("button_cancel")
            cancel_has_default = button_cancel.flags() & Gtk.HAS_DEFAULT
            button_prev = self.get("button_prev")
            prev_has_default = button_prev.flags() & Gtk.HAS_DEFAULT
    Severity: Major
    Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 1 day to fix
    lib/conf/gui/linux/prey-config.py on lines 219..231

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

    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 Operetta has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    var Operetta = function(args, scope) {
      if (args) {
        this.args = args;
      } else {
        if (process.argv[0].match(/node(\.exe)?$/))
    Severity: Minor
    Found in lib/conf/utils/operetta.js - About 1 day 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

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

    if __name__ == "__main__":
    
        parser = argparse.ArgumentParser(description="Shows an onscreen message.")
        parser.add_argument("message", metavar="message", help="Message to show")
        parser.add_argument(
    Severity: Major
    Found in lib/agent/actions/alert/linux/flash3.py and 1 other location - About 7 hrs to fix
    lib/agent/actions/alert/linux/flash.py on lines 243..253

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

    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

    if __name__ == "__main__":
    
      parser = argparse.ArgumentParser(description='Shows an onscreen message.')
      parser.add_argument('message', metavar='message', help='Message to show')
      parser.add_argument('-t', '--title', dest='title', default='', help='Title to show above.')
    Severity: Major
    Found in lib/agent/actions/alert/linux/flash.py and 1 other location - About 7 hrs to fix
    lib/agent/actions/alert/linux/flash3.py on lines 279..296

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

    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

    File index.js has 474 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable indent */
    // eslint-disable-next-line import/no-extraneous-dependencies
    const WebSocket = require('ws');
    // eslint-disable-next-line import/no-extraneous-dependencies
    const HttpsProxyAgent = require('https-proxy-agent');
    Severity: Minor
    Found in lib/agent/control-panel/websockets/index.js - About 7 hrs to fix

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

        def toggle_buttons(self, button, tab, tab_number):
      
          button_prev  = self.get('button_prev')
          button_next  = self.get('button_next')
          button_apply = self.get('button_apply')
      Severity: Major
      Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 7 hrs to fix
      lib/conf/gui/linux/prey-config3.py on lines 219..234

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

      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

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

          def toggle_buttons(self, button, tab, tab_number):
      
              button_prev = self.get("button_prev")
              button_next = self.get("button_next")
              button_apply = self.get("button_apply")
      Severity: Major
      Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 7 hrs to fix
      lib/conf/gui/linux/prey-config.py on lines 201..216

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

      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 activate has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.activate = (trigger) => {
        try {
          var index = trigger.automation_events.findIndex(
              (obj) => obj.type === 'exact_time' || obj.type === 'repeat_time'
            ),
      Severity: Minor
      Found in lib/agent/actions/triggers/index.js - About 7 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

      File package.js has 443 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const fs              = require('fs');
      const path            = require('path');
      const needle          = require('needle');
      const createHash      = require('crypto').createHash;
      const rmdir           = require('rimraf');
      Severity: Minor
      Found in lib/package.js - About 6 hrs to fix

        ConfigDelegate has 47 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ConfigDelegate(NSObject):
        
          def windowWillClose_(self, sender):
            self.terminate(sender)
        
        
        Severity: Minor
        Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 6 hrs to fix

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

            def apply_settings(self, button):
              self.get('button_apply').set_label(_("Saving..."))
          
              page_name = self.get_page_name()
              if page_name == 'new_user':
          Severity: Major
          Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 6 hrs to fix
          lib/conf/gui/linux/prey-config3.py on lines 274..285

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

          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

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

              def apply_settings(self, button):
                  self.get("button_apply").set_label(_("Saving..."))
          
                  page_name = self.get_page_name()
                  if page_name == "new_user":
          Severity: Major
          Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 6 hrs to fix
          lib/conf/gui/linux/prey-config.py on lines 255..266

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

          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 start has 158 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var start = function(cb) {
            ensureAndCreateDb((err)=>{
              if (err) return process.exit(1);
              const config = require('../utils/configfile');
              config.load(() => {
          Severity: Major
          Found in lib/conf/cli.js - About 6 hrs to fix
            Severity
            Category
            Status
            Source
            Language