Showing 224 of 370 total issues

Method setAlertFields has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function setAlertFields($data, $fields, $alog_action, $slog_action, $a=0, $b=0) {
        if(!$this->allowUpdate()) {
            throw new ForbiddenException;
        }

Severity: Major
Found in phplib/REST/Alerts.php - About 2 hrs to fix

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

            _render: function() {
                this.App.setTitle('Alert: ' + this.model.get('id'));
                this.registerView(new AlertNavbarView(this.App, {model: this.model}), true);
    
                this.App.registerSelectableGroup(this);
    Severity: Major
    Found in htdocs/assets/js/views/alerts/alert.js - About 2 hrs to fix

      File view.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      "use strict";
      define(function(require) {
          var $ = require('jquery'),
              _ = require('underscore'),
              Backbone = require('backbone'),
      Severity: Minor
      Found in htdocs/assets/js/view.js - About 2 hrs to fix

        Function run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run() {
                switch($this->obj['target_id']) {
                case static::I_HOURLY:
                    $type = Search::NT_HOURLY;
                    $range = 1 * 60 * 60;
        Severity: Minor
        Found in phplib/Job/Rollup.php - 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

        Method getAlertActivityCounts has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAlertActivityCounts($range, $search_id=0) {
                $client = self::getClient();
        
                $filter = [
                    [
        Severity: Major
        Found in phplib/ESClient.php - About 2 hrs to fix

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

              public function getActiveAlertCounts() {
                  $client = self::getClient();
          
                  $filter = [
                      [
          Severity: Minor
          Found in phplib/ESClient.php - 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 route has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public function route() {
                  $ret = self::format();
                  try {
                      $this->checkAuthorization();
          
          
          Severity: Minor
          Found in phplib/REST.php - 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

          Method stats has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function stats($data) {
                  if(!$this->allowRead()) {
                      throw new ForbiddenException;
                  }
          
          
          Severity: Major
          Found in phplib/REST/Searches.php - About 2 hrs to fix

            Function updateSelection has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    updateSelection: function() {
                        var data = {esc: 0, assign: 0, state: 0};
                        var elements = this.$('.alerts-table .alert-checkbox');
                        if(elements.length === 0) {
                            return;
            Severity: Minor
            Found in htdocs/assets/js/views/alerts/alertgroup.js - About 1 hr to fix

              Function initAssigneeSelect has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Method query has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function query($query, array $params=[], $ret_type=self::ALL) {
                        self::keepAlive();
                        list($query) = Hook::call('db.query', [$query]);
                
                        $stmt = self::$dbh->prepare($query);
                Severity: Minor
                Found in phplib/DB.php - About 1 hr to fix

                  Function POST has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function POST(array $get, array $data) {
                          $errors = [];
                  
                          // Loop over each object we need to process.
                          foreach($data as &$obj) {
                  Severity: Minor
                  Found in phplib/REST/Enrich.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 backfill has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function backfill($start_date, $end_date, $max_jobs=5) {
                          Logger::info('Scheduler backfill run', ['start' => $start_date, 'end' => $end_date], self::LOG_NAMESPACE);
                          cli_set_process_title('411] Backfill');
                          print "[+] Backfill: $start_date to $end_date\n";
                          $timer = new Timer();
                  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 process has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      Renderer.process = function(App, base_mapping, callback, preview) {
                          var remote_mapping = {};
                  
                          // First loop over each group of views.
                          for(var v in base_mapping) {
                  Severity: Minor
                  Found in htdocs/assets/js/views/renderer.js - About 1 hr to fix

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

                        protected function _execute($date, $constructed_qdata) {
                            // If our last_success_date is within 10 seconds of the start time, use that
                            // as the start time.
                            $from = $date - ($this->obj['range'] * 60);
                            if(abs($this->obj['last_success_date'] - $from) < 10) {
                    Severity: Minor
                    Found in phplib/Search/ECL.php - About 1 hr to fix

                      Method bootstrap has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function bootstrap($query, $from=null, $to=null) {
                              $client = self::getClient();
                      
                              $fields = ['escalated', 'assignee_type', 'assignee', 'search_id', 'state'];
                              $aggs = [];
                      Severity: Minor
                      Found in phplib/ESClient.php - About 1 hr to fix

                        Method route has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function route() {
                                $ret = self::format();
                                try {
                                    $this->checkAuthorization();
                        
                        
                        Severity: Minor
                        Found in phplib/REST.php - About 1 hr to fix

                          Function process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function process(Alert $alert, $date) {
                                  $script = self::$SCRIPTS[$this->obj['data']['script']];
                                  $spec = [
                                      0 => ['pipe', 'r'],
                                      1 => ['pipe', 'w'],
                          Severity: Minor
                          Found in phplib/Filter/Script.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 validateData has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function validateData(array $data) {
                                  parent::validateData($data);
                          
                                  if(strlen(trim($data['name'])) == 0) {
                                      throw new ValidationException('Invalid name');
                          Severity: Minor
                          Found in phplib/Search.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 _render has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  _render: function() {
                                      this.App.setTitle('Index');
                                      var user = this.App.Data.User;
                                      var vars = {
                                          logged_in: !!user,
                          Severity: Minor
                          Found in htdocs/assets/js/views/index.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language