From 455ee962b968393484092c3b4bb9e24327d9f106 Mon Sep 17 00:00:00 2001
From: Thibault Debatty <t.debatty@cylab.be>
Date: Sat, 17 Feb 2024 13:54:48 +0100
Subject: [PATCH] upgrade phpcs and fix style

---
 app/AgentScheduler.php                 | 14 ++++---
 app/Http/Controllers/ApiController.php |  7 ++--
 app/Jobs/RunAgent.php                  |  4 +-
 app/Jobs/StatusChangeDetection.php     |  4 +-
 app/Record.php                         |  4 +-
 app/Report.php                         |  4 +-
 app/Sensor/CPUtemperature.php          |  2 +-
 app/Sensor/ClientVersion.php           |  2 +-
 app/Sensor/Date.php                    |  2 +-
 app/Sensor/Disks.php                   |  4 +-
 app/Sensor/Ifconfig.php                |  2 +-
 app/Sensor/Inodes.php                  |  3 +-
 app/Sensor/ListeningPorts.php          |  2 +-
 app/Sensor/LoadAvg.php                 |  2 +-
 app/Sensor/MemInfo.php                 |  2 +-
 app/Sensor/Netstat.php                 |  2 +-
 app/Sensor/Perccli.php                 |  2 +-
 app/Sensor/Reboot.php                  |  2 +-
 app/Sensor/Ssacli.php                  |  4 +-
 app/Sensor/USBtemperature.php          |  2 +-
 app/Sensor/Updates.php                 |  2 +-
 app/Server.php                         |  5 +--
 app/ServerInfo.php                     |  2 +-
 app/Status.php                         |  4 +-
 composer.lock                          | 53 ++++++++++++++++++--------
 25 files changed, 80 insertions(+), 56 deletions(-)

diff --git a/app/AgentScheduler.php b/app/AgentScheduler.php
index 5b55535..8ec0514 100644
--- a/app/AgentScheduler.php
+++ b/app/AgentScheduler.php
@@ -19,7 +19,7 @@ class AgentScheduler
 {
     
     /**
-     * 
+     *
      * @var LazyCollection<Sensor>
      */
     private $sensors;
@@ -46,7 +46,7 @@ class AgentScheduler
     }
     
     /**
-     * 
+     *
      * @return LazyCollection<Sensor>
      */
     public function sensors() : LazyCollection
@@ -55,7 +55,7 @@ class AgentScheduler
     }
     
     /**
-     * 
+     *
      * @return LazyCollection<Sensor>
      */
     public function autodiscover() : LazyCollection
@@ -74,7 +74,7 @@ class AgentScheduler
     }
     
     /**
-     * 
+     *
      * @param LazyCollection<Sensor> $sensors
      * @return array
      */
@@ -92,12 +92,14 @@ class AgentScheduler
     
     /**
      * Get the list of defined agent labels.
-     * 
+     *
      * @return array
      */
     public function agentLabel() : array
     {
-        return $this->sensors->map(function(Sensor $sensor) {return $sensor->config()->label; })->toArray();
+        return $this->sensors->map(function (Sensor $sensor) {
+            return $sensor->config()->label;
+        })->toArray();
     }
     
     // ------------------ SCHEDULING of agents
diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php
index fe98d11..1efd388 100644
--- a/app/Http/Controllers/ApiController.php
+++ b/app/Http/Controllers/ApiController.php
@@ -7,7 +7,8 @@ use App\Record;
 
 use Illuminate\Http\Request;
 
-class ApiController extends Controller {
+class ApiController extends Controller
+{
 
     public function echo(Request $request, Server $server)
     {
@@ -58,7 +59,7 @@ class ApiController extends Controller {
             "max" => $server->info()->cpuinfo()["threads"]];
     }
     
-    public function ifconfig (Server $server, string $token)
+    public function ifconfig(Server $server, string $token)
     {
         if ($server->read_token != $token) {
             abort(403);
@@ -69,7 +70,7 @@ class ApiController extends Controller {
         return $sensor->points($server->lastRecords("ifconfig"));
     }
     
-    public function netstat (Server $server, string $token)
+    public function netstat(Server $server, string $token)
     {
         if ($server->read_token != $token) {
             abort(403);
diff --git a/app/Jobs/RunAgent.php b/app/Jobs/RunAgent.php
index 661937e..db2eabf 100644
--- a/app/Jobs/RunAgent.php
+++ b/app/Jobs/RunAgent.php
@@ -16,14 +16,14 @@ class RunAgent implements ShouldQueue
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
     
     /**
-     * 
+     *
      * @var Sensor
      */
     public $agent;
     
     
     /**
-     * 
+     *
      * @var Server
      */
     public $server;
diff --git a/app/Jobs/StatusChangeDetection.php b/app/Jobs/StatusChangeDetection.php
index c7df749..3cedb35 100644
--- a/app/Jobs/StatusChangeDetection.php
+++ b/app/Jobs/StatusChangeDetection.php
@@ -45,7 +45,7 @@ class StatusChangeDetection implements ShouldQueue
             $change = new StatusChange();
             $change->server_id = $server->id;
             $change->time = time();
-            $change->status = $current_status->code();            
+            $change->status = $current_status->code();
             $change->save();
             return;
         }
@@ -55,7 +55,7 @@ class StatusChangeDetection implements ShouldQueue
             return;
         }
         
-        Log::notice("Status of server changed to " . $current_status->code() . 
+        Log::notice("Status of server changed to " . $current_status->code() .
                 " for server #" . $server->id);
 
         $change = new StatusChange();
diff --git a/app/Record.php b/app/Record.php
index ca5801b..d12fac4 100644
--- a/app/Record.php
+++ b/app/Record.php
@@ -21,9 +21,9 @@ class Record extends Model
         return $this->belongsTo(Server::class);
     }
     
-    public function save(array $options = []) {
+    public function save(array $options = [])
+    {
         if (parent::save($options)) {
-        
             AgentScheduler::get()->notify($this);
             return true;
         }
diff --git a/app/Report.php b/app/Report.php
index d21932e..030280a 100644
--- a/app/Report.php
+++ b/app/Report.php
@@ -11,12 +11,12 @@ use Illuminate\Database\Eloquent\Model;
  * @property integer $time
  * @property integer $server_id
  * @property string $label
- * 
+ *
  * Properties set by analysis agent:
  * @property int $status_code
  * @property string $title
  * @property string $html
- * 
+ *
  * @author tibo
  */
 class Report extends Model implements HasStatus
diff --git a/app/Sensor/CPUtemperature.php b/app/Sensor/CPUtemperature.php
index cfa5228..c26f250 100644
--- a/app/Sensor/CPUtemperature.php
+++ b/app/Sensor/CPUtemperature.php
@@ -34,7 +34,7 @@ class CPUtemperature implements Sensor
     {
         $report = (new Report())->setTitle("CPU temperature");
         
-        $record = $records->last();        
+        $record = $records->last();
         $cpus = $this->parse($record->data);
         $report->setHTML(view("sensor.cputemperature", ["cpus" => $cpus]));
         $report->setStatus(Status::max($cpus));
diff --git a/app/Sensor/ClientVersion.php b/app/Sensor/ClientVersion.php
index 600d071..ce1611a 100644
--- a/app/Sensor/ClientVersion.php
+++ b/app/Sensor/ClientVersion.php
@@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class ClientVersion implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("client-version", "version");
     }
diff --git a/app/Sensor/Date.php b/app/Sensor/Date.php
index fa75808..2e1857b 100644
--- a/app/Sensor/Date.php
+++ b/app/Sensor/Date.php
@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class Date implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("date", "date");
     }
diff --git a/app/Sensor/Disks.php b/app/Sensor/Disks.php
index 3edc3eb..2469d40 100644
--- a/app/Sensor/Disks.php
+++ b/app/Sensor/Disks.php
@@ -18,7 +18,7 @@ use Illuminate\Support\Collection;
  */
 class Disks implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("disks", "disks");
     }
@@ -38,7 +38,7 @@ class Disks implements Sensor
     }
 
     /**
-     * 
+     *
      * @param string $string
      * @return Collection<Partition>
      */
diff --git a/app/Sensor/Ifconfig.php b/app/Sensor/Ifconfig.php
index ae90db3..2fcefb4 100644
--- a/app/Sensor/Ifconfig.php
+++ b/app/Sensor/Ifconfig.php
@@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class Ifconfig implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("ifconfig", "ifconfig");
     }
diff --git a/app/Sensor/Inodes.php b/app/Sensor/Inodes.php
index 2e619c2..1d2c8e1 100644
--- a/app/Sensor/Inodes.php
+++ b/app/Sensor/Inodes.php
@@ -10,6 +10,7 @@ use App\Status;
 
 use Illuminate\Database\Eloquent\Collection as DatabaseCollection;
 use Illuminate\Support\Collection;
+
 /**
  * Description of Update
  *
@@ -17,7 +18,7 @@ use Illuminate\Support\Collection;
  */
 class Inodes implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("inodes", "inodes");
     }
diff --git a/app/Sensor/ListeningPorts.php b/app/Sensor/ListeningPorts.php
index d951081..cc050a5 100644
--- a/app/Sensor/ListeningPorts.php
+++ b/app/Sensor/ListeningPorts.php
@@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection;
 class ListeningPorts implements Sensor
 {
     
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("listening-tcp", "netstat-listen-tcp");
     }
diff --git a/app/Sensor/LoadAvg.php b/app/Sensor/LoadAvg.php
index 17601d4..4d730eb 100644
--- a/app/Sensor/LoadAvg.php
+++ b/app/Sensor/LoadAvg.php
@@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class LoadAvg implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("loadavg", "loadavg");
     }
diff --git a/app/Sensor/MemInfo.php b/app/Sensor/MemInfo.php
index cf6ff87..6070104 100644
--- a/app/Sensor/MemInfo.php
+++ b/app/Sensor/MemInfo.php
@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class MemInfo implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("memory", "memory");
     }
diff --git a/app/Sensor/Netstat.php b/app/Sensor/Netstat.php
index d823200..4d78d7f 100644
--- a/app/Sensor/Netstat.php
+++ b/app/Sensor/Netstat.php
@@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection;
 class Netstat implements Sensor
 {
     
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("netstat-retransmitted", "netstat-statistics");
     }
diff --git a/app/Sensor/Perccli.php b/app/Sensor/Perccli.php
index 8922765..1924223 100644
--- a/app/Sensor/Perccli.php
+++ b/app/Sensor/Perccli.php
@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class Perccli implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("perccli", "perccli");
     }
diff --git a/app/Sensor/Reboot.php b/app/Sensor/Reboot.php
index 6cf1d22..17793cc 100644
--- a/app/Sensor/Reboot.php
+++ b/app/Sensor/Reboot.php
@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class Reboot implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("reboot", "reboot");
     }
diff --git a/app/Sensor/Ssacli.php b/app/Sensor/Ssacli.php
index 42411ed..8516edc 100644
--- a/app/Sensor/Ssacli.php
+++ b/app/Sensor/Ssacli.php
@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class Ssacli implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("ssacli", "ssacli");
     }
@@ -28,7 +28,7 @@ class Ssacli implements Sensor
     {
         $report = (new Report())->setTitle("HP ssacli");
         
-        $record = $records->last();        
+        $record = $records->last();
         $disks = $this->parse($record->data);
         $report->setHTML(view("sensor.ssacli", ["disks" => $disks]));
         
diff --git a/app/Sensor/USBtemperature.php b/app/Sensor/USBtemperature.php
index 9ac2384..159671b 100644
--- a/app/Sensor/USBtemperature.php
+++ b/app/Sensor/USBtemperature.php
@@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection;
  */
 class USBtemperature implements Sensor
 {
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("usb-temperature", "TEMPer");
     }
diff --git a/app/Sensor/Updates.php b/app/Sensor/Updates.php
index 4fe3766..b9330e5 100644
--- a/app/Sensor/Updates.php
+++ b/app/Sensor/Updates.php
@@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection;
 class Updates implements Sensor
 {
     
-    public function config(): SensorConfig 
+    public function config(): SensorConfig
     {
         return new SensorConfig("updates", "updates");
     }
diff --git a/app/Server.php b/app/Server.php
index bcdb25f..06a4660 100644
--- a/app/Server.php
+++ b/app/Server.php
@@ -88,7 +88,7 @@ class Server extends Model
     public function lastRecord(string $label) : ?Record
     {
         return $this->records()
-                ->where ("label", $label)
+                ->where("label", $label)
                 ->orderBy("time", "desc")->first();
     }
 
@@ -103,7 +103,6 @@ class Server extends Model
                 ->where("time", ">", $start)
                 ->orderBy("time")
                 ->get();
-        
     }
 
     public function hasData() : bool
@@ -160,7 +159,7 @@ class Server extends Model
         return $reports->filter();
     }
     
-    public function lastReport (string $label) : ?Report
+    public function lastReport(string $label) : ?Report
     {
         $start = time() - 24 * 3600;
         return $this->reports()
diff --git a/app/ServerInfo.php b/app/ServerInfo.php
index 78ecacd..2664534 100644
--- a/app/ServerInfo.php
+++ b/app/ServerInfo.php
@@ -24,7 +24,7 @@ class ServerInfo
     private $parser;
     
     /**
-     * 
+     *
      * @var Server
      */
     private $server;
diff --git a/app/Status.php b/app/Status.php
index a21b679..1ce71a5 100644
--- a/app/Status.php
+++ b/app/Status.php
@@ -2,8 +2,6 @@
 
 namespace App;
 
-use Illuminate\Support\Collection;
-
 /**
  * Wrapper around a status code
  */
@@ -87,7 +85,7 @@ class Status
             return self::maxArray($items);
         }
         
-       return self::maxCollection($items);
+        return self::maxCollection($items);
     }
     
     private static function maxArray(array $items) : Status
diff --git a/composer.lock b/composer.lock
index 49723b7..ad39082 100644
--- a/composer.lock
+++ b/composer.lock
@@ -7900,16 +7900,16 @@
         },
         {
             "name": "squizlabs/php_codesniffer",
-            "version": "3.7.2",
+            "version": "3.9.0",
             "source": {
                 "type": "git",
-                "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
-                "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879"
+                "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
+                "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879",
-                "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879",
+                "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b",
+                "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b",
                 "shasum": ""
             },
             "require": {
@@ -7919,11 +7919,11 @@
                 "php": ">=5.4.0"
             },
             "require-dev": {
-                "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+                "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
             },
             "bin": [
-                "bin/phpcs",
-                "bin/phpcbf"
+                "bin/phpcbf",
+                "bin/phpcs"
             ],
             "type": "library",
             "extra": {
@@ -7938,22 +7938,45 @@
             "authors": [
                 {
                     "name": "Greg Sherwood",
-                    "role": "lead"
+                    "role": "Former lead"
+                },
+                {
+                    "name": "Juliette Reinders Folmer",
+                    "role": "Current lead"
+                },
+                {
+                    "name": "Contributors",
+                    "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
                 }
             ],
             "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
-            "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
+            "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
             "keywords": [
                 "phpcs",
                 "standards",
                 "static analysis"
             ],
             "support": {
-                "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
-                "source": "https://github.com/squizlabs/PHP_CodeSniffer",
-                "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
+                "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
+                "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
+                "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+                "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
             },
-            "time": "2023-02-22T23:07:41+00:00"
+            "funding": [
+                {
+                    "url": "https://github.com/PHPCSStandards",
+                    "type": "github"
+                },
+                {
+                    "url": "https://github.com/jrfnl",
+                    "type": "github"
+                },
+                {
+                    "url": "https://opencollective.com/php_codesniffer",
+                    "type": "open_collective"
+                }
+            ],
+            "time": "2024-02-16T15:06:51+00:00"
         },
         {
             "name": "symfony/filesystem",
@@ -8191,5 +8214,5 @@
         "php": ">=7.4"
     },
     "platform-dev": [],
-    "plugin-api-version": "2.3.0"
+    "plugin-api-version": "2.6.0"
 }
-- 
GitLab