Showing 370 of 370 total issues

Function formatTime has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function formatTime(mins) {
        var weeks = 0;
        var days = 0;
        var hours = 0;
        mins = parseInt(mins, 10);
Severity: Minor
Found in htdocs/assets/js/util.js - About 1 hr to fix

    Function initUserSelect has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var initUserSelect = function(elems, users, search, options) {
            options = options || {};
    
            var user_search = function(q) {
                var term = q.term.toLowerCase();
    Severity: Minor
    Found in htdocs/assets/js/util.js - About 1 hr to fix

      Function destroyElement has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              destroyElement: function(k) {
                  var elems = this.childElements[k];
                  if(_.isUndefined(elems)) {
                      throw 'Called destroyChild on unknown key: ' + k;
                  }
      Severity: Minor
      Found in htdocs/assets/js/view.js - About 1 hr to fix

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

            public static function serialize($arr) {
                $s_arr = [];
        
                if(is_null($arr)) {
                    return 'null';
        Severity: Minor
        Found in phplib/Logger.php - 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 generateTypeData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            private function generateTypeData($types) {
                $type_names = [];
                if(Auth::isAuthenticated()) {
                    foreach($types as $type) {
                        $data = [];
        Severity: Minor
        Found in phplib/REST/Data.php - 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

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

                    if('assignee' in query) {
                        var assignee = Util.parseAssignee(query.assignee);
                        query.assignee_type = assignee[0];
                        query.assignee = assignee[1];
                    }
        Severity: Major
        Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 1 hr to fix
        htdocs/assets/js/views/searches/searches.js on lines 83..87

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

        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

                    if('assignee' in query) {
                        var assignee = Util.parseAssignee(query.assignee);
                        query.assignee_type = assignee[0];
                        query.assignee = assignee[1];
                    }
        Severity: Major
        Found in htdocs/assets/js/views/searches/searches.js and 1 other location - About 1 hr to fix
        htdocs/assets/js/views/alerts/alerts.js on lines 77..81

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

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

            private function health($date) {
                $search_health = [];
        
                $cfg = new DBConfig;
                $meta = new DBMeta;
        Severity: Minor
        Found in phplib/Scheduler.php - 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 query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            private function query($query, $fields=null, $from=null, $to=null, $scroll=false, $offset=null, $count=null) {
                $client = self::getClient();
        
                $filter = [];
                $conds = [];
        Severity: Minor
        Found in phplib/ESClient.php - 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

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

                selectAction: function(action) {
                    switch(action) {
                        case 'open': this.open(); break;
                        case 'pdf': this.generatePDF(); break;
                        case 'csv': this.generateCSV(); break;
        Severity: Major
        Found in htdocs/assets/js/views/reports/reports.js and 1 other location - About 1 hr to fix
        htdocs/assets/js/views/alerts/alertgroup.js on lines 162..168

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

        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

                selectAction: function(action) {
                    switch(action) {
                        case 'open': this.open(); break;
                        case 'select': this.select(); break;
                        case 'source': this.source(); break;
        Severity: Major
        Found in htdocs/assets/js/views/alerts/alertgroup.js and 1 other location - About 1 hr to fix
        htdocs/assets/js/views/reports/reports.js on lines 36..42

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

        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

        Method run has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function run() {
                // Grab a list of jobs that have autoclosing enabled.
                $searches = SearchFinder::getByQuery(['autoclose_threshold' => [
                    ModelFinder::C_GT => 0
                ]]);
        Severity: Minor
        Found in phplib/Job/Autoclose.php - About 1 hr to fix

          Function _render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  _render: function() {
                      // These attributes are initialized here because we occasionally
                      // need to rerender the View.
                      this.columns = [];
                      this.keys = [];
          Severity: Minor
          Found in htdocs/assets/js/views/alerts/alertgroup.js - About 1 hr to fix

            Method process has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function process() {
                    Logger::info('Worker run', [], self::LOG_NAMESPACE);
                    cli_set_process_title('411] Worker');
                    print "[+] Worker\n";
                    $timer = new Timer();
            Severity: Minor
            Found in phplib/Worker.php - About 1 hr to fix

              Method validateField has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function validateField($field, $settings, $value) {
                      $ok = false;
                      switch($settings[0]) {
                          case static::T_BOOL:
                              $ok = is_bool($value);
              Severity: Minor
              Found in phplib/Model.php - About 1 hr to fix

                Method _execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function _execute($date, $constructed_qdata) {
                        $tecfg = $this->getConfig();
                        if(is_null($tecfg['api_token']) || is_null($tecfg['api_secret'])) {
                            throw new SearchException('Threatexchange not configured');
                        }
                Severity: Minor
                Found in phplib/Search/ThreatExchange.php - About 1 hr to fix

                  Method offsetSet has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function offsetSet($key, $value) {
                          $schema = static::getSchema();
                          if(array_key_exists($key, $this->obj)) {
                              switch($schema[$key][0]) {
                                  case static::T_BOOL:
                  Severity: Minor
                  Found in phplib/Model.php - About 1 hr to fix

                    Method mail has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function mail($to, $from, $title, $message, $file=null) {
                            list($to, $from, $title, $message, $file) = Hook::call('mail', [$to, $from, $title, $message, $file]);
                            $to = (array) $to;
                    
                            $bnd = uniqid();
                    Severity: Minor
                    Found in phplib/Notification.php - About 1 hr to fix

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

                                  }, {
                                      success: this.cbRendered(function(resp) {
                                          this.App.addMessage('Sent ' + resp.count + ' alerts', 2);
                                          this.hide();
                                      }),
                      Severity: Major
                      Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 1 hr to fix
                      htdocs/assets/js/views/alerts/actions.js on lines 110..115

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

                      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

                                  AlertCollection.whitelist(data, {
                                      success: this.cbRendered(function(resp) {
                                          this.App.addMessage('Whitelisted ' + resp.count + ' alerts', 2);
                                          this.hide();
                                      }),
                      Severity: Major
                      Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 1 hr to fix
                      htdocs/assets/js/views/alerts/actions.js on lines 72..77

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language