Showing 224 of 370 total issues

Function hydrateModels has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function hydrateModels($objs) {
        $models = [];
        foreach($objs as $obj) {
            foreach(array_keys($obj) as $key) {
                // If a value is numeric, cast it into an int.
Severity: Minor
Found in phplib/Model.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 parseDates has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parseDates($format, array $dates) {
        $ret = [];
        switch($format) {
        case '#':
            $ret = $dates;
Severity: Minor
Found in phplib/Util.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 filterSearchesFunc has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var filterSearchesFunc = function(collection, query) {
        for(var k in query) {
            if(!_.isArray(query[k])) {
                query[k] = [query[k]];
            }
Severity: Minor
Found in htdocs/assets/js/views/searches/searches.js - About 1 hr to fix

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

            _render: function() {
                var sidelinks = [
                    {name: 'Keyboard shortcuts', action: 'shortcuts'},
                    {name: 'Message history', action: 'messages'}
                ];
    Severity: Minor
    Found in htdocs/assets/js/views/header.js - About 1 hr to fix

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

              readForm: function() {
                  var form = this.$('#search-form');
                  var data = Util.serializeForm(form);
      
                  // schedule_type is an int.
      Severity: Minor
      Found in htdocs/assets/js/views/searches/search.js - About 1 hr to fix

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

                update: function() {
                    var query = Util.parseQuery(window.location.href);
        
                    var processResults = this.cbRendered(function(resp) {
                        this.collections = [];
        Severity: Minor
        Found in htdocs/assets/js/views/alerts/alerts.js - About 1 hr to fix

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

              public function process(Alert $alert, $date) {
                  $site = SiteFinder::getCurrent();
                  $search = SearchFinder::getById($alert['search_id']);
                  $issue_key = null;
          
          
          Severity: Minor
          Found in phplib/Target/Jira.php - About 1 hr to fix

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

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

              Function App has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var App = function() {
                      // Store a global collection of each type. This allows for caching objects between pages.
                      this.Data = {
                          Searches: new SearchCollection(),
                          Alerts: new AlertCollection(),
              Severity: Minor
              Found in htdocs/assets/js/app.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                            if(
                                !('href' in anchor) ||
                                anchor.target === '_blank' ||
                                anchor.href.length === 0 ||
                                anchor.href.indexOf('#') !== -1 ||
                Severity: Critical
                Found in htdocs/assets/js/app.js - About 1 hr to fix

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

                      public function run() {
                          $cfg = new DBConfig;
                          $dt = new \DateTime('@' . $this->obj['target_date']);
                          $dt->setTime(0, 0, 0);
                          $end_ts = $dt->getTimestamp();
                  Severity: Minor
                  Found in phplib/Job/Summary.php - About 1 hr to fix

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

                            initializeCollection: function(params) {
                                var arr = this.initializeCollectionData(params);
                                var models = arr[0],
                                    frag = arr[1];
                    
                    
                    Severity: Minor
                    Found in htdocs/assets/js/views/table.js - About 1 hr to fix

                      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

                            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

                            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
                              Severity
                              Category
                              Status
                              Source
                              Language