| @@ 79-105 (lines=27) @@ | ||
| 76 | public function begin_rule(Rule $rule) { |
|
| 77 | assert('$this->current_run_id !== null'); |
|
| 78 | $rule_id = $this->rule_id($rule); |
|
| 79 | if ($rule_id === null) { |
|
| 80 | $this->builder() |
|
| 81 | ->insert("rules") |
|
| 82 | ->values(array |
|
| 83 | ( "rule" => "?" |
|
| 84 | , "first_seen" => "?" |
|
| 85 | , "last_seen" => "?" |
|
| 86 | , "explanation" => "?" |
|
| 87 | )) |
|
| 88 | ->setParameter(0, $rule->pprint()) |
|
| 89 | ->setParameter(1, $this->current_run_id) |
|
| 90 | ->setParameter(2, $this->current_run_id) |
|
| 91 | ->setParameter(3, $rule->explanation()) |
|
| 92 | ->execute(); |
|
| 93 | $rule_id = (int)$this->connection->lastInsertId(); |
|
| 94 | } |
|
| 95 | else { |
|
| 96 | $this->builder() |
|
| 97 | ->update("rules") |
|
| 98 | ->set("last_seen", "?") |
|
| 99 | ->set("explanation", "?") |
|
| 100 | ->where("id = ?") |
|
| 101 | ->setParameter(0, $this->current_run_id) |
|
| 102 | ->setParameter(1, $rule->explanation()) |
|
| 103 | ->setParameter(2, $rule_id) |
|
| 104 | ->execute(); |
|
| 105 | } |
|
| 106 | foreach ($rule->variables() as $variable) { |
|
| 107 | $this->upsert_variable($variable); |
|
| 108 | } |
|
| @@ 126-152 (lines=27) @@ | ||
| 123 | assert('$this->current_run_id !== null'); |
|
| 124 | assert('$this->current_rule_id !== null'); |
|
| 125 | $violation_id = $this->violation_id($violation); |
|
| 126 | if ($violation_id === null) { |
|
| 127 | $this->builder() |
|
| 128 | ->insert("violations") |
|
| 129 | ->values(array |
|
| 130 | ( "rule_id" => "?" |
|
| 131 | , "file" => "?" |
|
| 132 | , "line" => "?" |
|
| 133 | , "first_seen" => "?" |
|
| 134 | , "last_seen" => "?" |
|
| 135 | )) |
|
| 136 | ->setParameter(0, $this->current_rule_id) |
|
| 137 | ->setParameter(1, $violation->filename()) |
|
| 138 | ->setParameter(2, $violation->line()) |
|
| 139 | ->setParameter(3, $this->current_run_id) |
|
| 140 | ->setParameter(4, $this->current_run_id) |
|
| 141 | ->execute(); |
|
| 142 | $violation_id = (int)$this->connection->lastInsertId(); |
|
| 143 | } |
|
| 144 | else { |
|
| 145 | $this->builder() |
|
| 146 | ->update("violations") |
|
| 147 | ->set("last_seen", "?") |
|
| 148 | ->where("id = ?") |
|
| 149 | ->setParameter(0, $this->current_run_id) |
|
| 150 | ->setParameter(1, $violation_id) |
|
| 151 | ->execute(); |
|
| 152 | } |
|
| 153 | ||
| 154 | $this->builder() |
|
| 155 | ->insert("violation_locations") |
|