Showing 224 of 370 total issues

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

    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

              Method whitelistAlerts has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function whitelistAlerts($data) {
                      if(!$this->allowUpdate()) {
                          throw new ForbiddenException;
                      }
              
              
              Severity: Minor
              Found in phplib/REST/Alerts.php - About 1 hr to fix

                Method afterStore has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function afterStore($model, $data, $new, $delete) {
                        $fields = ['tags', 'priority', 'category', 'owner'];
                
                        // Trigger a job to delete all Alerts if the Search was deleted.
                        if($delete) {
                Severity: Minor
                Found in phplib/REST/Searches.php - About 1 hr to fix

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

                      public function process(Alert $alert, $date) {
                          $site = SiteFinder::getCurrent();
                  
                          $alert_url = $site->urlFor('/');
                          if(!$alert->isNew()) {
                  Severity: Minor
                  Found in phplib/Target/PagerDuty.php - About 1 hr to fix

                    Method generateClauses has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected static function generateClauses($count=null, $offset=null, $sort=[], $group=[], $reverse=null) {
                            $MODEL = 'FOO\\' . static::$MODEL;
                    
                            $clauses = [];
                            $order = [];
                    Severity: Minor
                    Found in phplib/Model.php - About 1 hr to fix

                      Method generateSchema has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected static function generateSchema() {
                              return [
                                  'name' => [self::T_STR, null, ''],
                                  'source' => [self::T_STR, null, ''],
                                  'query_data' => [self::T_OBJ, null, []],
                      Severity: Minor
                      Found in phplib/Search.php - About 1 hr to fix

                        Function registerView has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                registerView: function(view, init, sel, str) {
                                    if(_.isUndefined(str)) str = view.cid;
                                    if(_.isUndefined(sel)) sel = this.$el;
                                    var arr = str.substr(-2) === '[]';
                                    if(this.childViewNamesToIDs[str] && !arr) {
                        Severity: Minor
                        Found in htdocs/assets/js/view.js - About 1 hr to fix

                          Function initTimeSelect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              var initTimeSelect = function(elems, options) {
                                  options = options || {};
                          
                                  var fmt = options.format || formatTime;
                                  var intvs = [1, 5, 10, 15, 30, 60, 90, 120, 180, 360, 720, 1440, 2880, 4320, 10080, 20160];
                          Severity: Minor
                          Found in htdocs/assets/js/util.js - About 1 hr to fix

                            Method sendAlerts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function sendAlerts($data) {
                                    if(!$this->allowUpdate()) {
                                        throw new ForbiddenException;
                                    }
                            
                            
                            Severity: Minor
                            Found in phplib/REST/Alerts.php - About 1 hr to fix

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

                                      _render: function() {
                                          var search = this.App.Data.Searches.get(this.model.get('search_id'));
                                          var vars = this.model.toJSON();
                                          _.extend(vars, {
                                              preview: this.preview,
                              Severity: Minor
                              Found in htdocs/assets/js/views/alerts/alertgroup.js - About 1 hr to fix

                                Method generateWhere has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected static function generateWhere(array $query) {
                                        $MODEL = 'FOO\\' . static::$MODEL;
                                
                                        $clauses = [];
                                        $vals = [];
                                Severity: Minor
                                Found in phplib/Model.php - About 1 hr to fix

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

                                      public function afterStore($model, $data, $new, $delete) {
                                          $fields = ['tags', 'priority', 'category', 'owner'];
                                  
                                          // Trigger a job to delete all Alerts if the Search was deleted.
                                          if($delete) {
                                  Severity: Minor
                                  Found in phplib/REST/Searches.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 POST has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function POST(array $get, array $data) {
                                          $cfg = new DBConfig();
                                  
                                          foreach(self::$FIELDS as $field=>$type) {
                                              $val = Util::get($data, $field);
                                  Severity: Minor
                                  Found in phplib/REST/Admin.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function process(Alert $alert, $date) {
                                          $data = $this->obj['data'];
                                          $include = Util::get($data, 'include', true);
                                          $keys = [Util::get($data, 'key', '*')];
                                          if ($keys[0] == '*') {
                                  Severity: Minor
                                  Found in phplib/Filter/Regex.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 a Cognitive Complexity of 10 (exceeds 5 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

                                  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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language