Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robust code #3751

Closed
szepeviktor opened this issue Aug 21, 2019 · 7 comments
Closed

Robust code #3751

szepeviktor opened this issue Aug 21, 2019 · 7 comments
Labels

Comments

@szepeviktor
Copy link
Contributor

Please consider adding static analysis to your workflow.

composer require --dev nunomaduro/larastan phpstan/phpstan

php artisan code:analyse -l 0 Levels go up to 7.

It is like adding 100 pairs of 👀

@welcome
Copy link

welcome bot commented Aug 21, 2019

👋 Thank you for opening your first issue. I'm just an automated bot that's here to help you get the information you need quicker, so please ignore this message if it doesn't apply to your issue.
If you're looking for support, you should try the Slack group by registering your email address at https://cachethq-slack.herokuapp.com. Alternatively, email [email protected] for our Professional support service (please note, this a paid service.)
If you're issue is with documentation, you can suggest edits by clicking the Suggest Edits link on any page, or open an issue at https://github.com/CachetHQ/Docs

@diegosouza
Copy link
Contributor

@szepeviktor would you like to send a pull request? I can help you.

@szepeviktor
Copy link
Contributor Author

@diegosouza I think some things need to be fixed to get it up and running even on Level 0

$ php artisan code:analyse -l 0
 311/311 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------------------------------------------------------------------
  Line   app/Console/Commands/InstallCommand.php
 ------ -------------------------------------------------------------------------------------------------------
  178    Result of method CachetHQ\Cachet\Console\Commands\InstallCommand::configureDatabase() (void) is used.
  250    Result of method CachetHQ\Cachet\Console\Commands\InstallCommand::configureDrivers() (void) is used.
  308    Result of method CachetHQ\Cachet\Console\Commands\InstallCommand::configureMail() (void) is used.
 ------ -------------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------
  Line   app/Http/Controllers/Api/ComponentController.php
 ------ --------------------------------------------------
  76     Result of function execute (void) is used.
 ------ --------------------------------------------------

 ------ -------------------------------------------------------
  Line   app/Http/Controllers/Api/ComponentGroupController.php
 ------ -------------------------------------------------------
  95     Result of function execute (void) is used.
  118    Result of function execute (void) is used.
 ------ -------------------------------------------------------

 ------ -------------------------------------------------
  Line   app/Http/Controllers/Api/IncidentController.php
 ------ -------------------------------------------------
  70     Result of function execute (void) is used.
  101    Result of function execute (void) is used.
 ------ -------------------------------------------------

 ------ -------------------------------------------------------
  Line   app/Http/Controllers/Api/IncidentUpdateController.php
 ------ -------------------------------------------------------
  77     Result of function execute (void) is used.
  103    Result of function execute (void) is used.
 ------ -------------------------------------------------------

 ------ -----------------------------------------------
  Line   app/Http/Controllers/Api/MetricController.php
 ------ -----------------------------------------------
  65     Result of function execute (void) is used.
  95     Result of function execute (void) is used.
 ------ -----------------------------------------------

 ------ ----------------------------------------------------
  Line   app/Http/Controllers/Api/MetricPointController.php
 ------ ----------------------------------------------------
  51     Result of function execute (void) is used.
  73     Result of function execute (void) is used.
 ------ ----------------------------------------------------

 ------ -------------------------------------------------
  Line   app/Http/Controllers/Api/ScheduleController.php
 ------ -------------------------------------------------
  70     Result of function execute (void) is used.
  96     Result of function execute (void) is used.
 ------ -------------------------------------------------

 ------ ---------------------------------------------------
  Line   app/Http/Controllers/Api/SubscriberController.php
 ------ ---------------------------------------------------
  53     Result of function execute (void) is used.
 ------ ---------------------------------------------------

 ------ --------------------------------------------------------
  Line   app/Http/Controllers/Dashboard/ComponentController.php
 ------ --------------------------------------------------------
  114    Result of function execute (void) is used.
  160    Result of function execute (void) is used.
 ------ --------------------------------------------------------

 ------ -------------------------------------------------------------
  Line   app/Http/Controllers/Dashboard/ComponentGroupController.php
 ------ -------------------------------------------------------------
  129    Result of function execute (void) is used.
  156    Result of function execute (void) is used.
 ------ -------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------
  Line   app/Http/Controllers/Dashboard/DashboardController.php                                                         
 ------ ----------------------------------------------------------------------------------------------------------------
  75     Access to an undefined property CachetHQ\Cachet\Http\Controllers\Dashboard\DashboardController::$dateTimeZone. 
  137    Access to an undefined property CachetHQ\Cachet\Http\Controllers\Dashboard\DashboardController::$dateTimeZone. 
  142    Access to an undefined property CachetHQ\Cachet\Http\Controllers\Dashboard\DashboardController::$dateTimeZone. 
  169    Access to an undefined property CachetHQ\Cachet\Http\Controllers\Dashboard\DashboardController::$dateTimeZone. 
  174    Access to an undefined property CachetHQ\Cachet\Http\Controllers\Dashboard\DashboardController::$dateTimeZone. 
 ------ ----------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------
  Line   app/Http/Controllers/Dashboard/IncidentController.php
 ------ -------------------------------------------------------
  120    Result of function execute (void) is used.
  250    Result of function execute (void) is used.
 ------ -------------------------------------------------------

 ------ -------------------------------------------------------------
  Line   app/Http/Controllers/Dashboard/IncidentUpdateController.php
 ------ -------------------------------------------------------------
  104    Result of function execute (void) is used.
  154    Result of function execute (void) is used.
 ------ -------------------------------------------------------------

 ------ -------------------------------------------------------
  Line   app/Http/Controllers/Dashboard/ScheduleController.php
 ------ -------------------------------------------------------
  141    Result of function execute (void) is used.
 ------ -------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------
  Line   app/Http/Controllers/SetupController.php
 ------ -------------------------------------------------------------------------------------------
  143    Access to an undefined property CachetHQ\Cachet\Http\Controllers\SetupController::$langs.
 ------ -------------------------------------------------------------------------------------------

 ------ ----------------------------------------------
  Line   app/Http/Controllers/SubscribeController.php
 ------ ----------------------------------------------
  84     Result of function execute (void) is used.
 ------ ----------------------------------------------

 ------ ------------------------------------------------------------------------------------------------
  Line   app/Http/Middleware/RemoteUserAuthenticate.php
 ------ ------------------------------------------------------------------------------------------------
  30     Access to an undefined property CachetHQ\Cachet\Http\Middleware\RemoteUserAuthenticate::$auth.
  46     Access to an undefined property CachetHQ\Cachet\Http\Middleware\RemoteUserAuthenticate::$auth.
  47     Access to an undefined property CachetHQ\Cachet\Http\Middleware\RemoteUserAuthenticate::$auth.
 ------ ------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------
  Line   app/Http/Middleware/TrustProxies.php
 ------ ---------------------------------------------------------------------------------------------------
  44     CachetHQ\Cachet\Http\Middleware\TrustProxies::__construct() does not call parent constructor from
         Fideloper\Proxy\TrustProxies.
 ------ ---------------------------------------------------------------------------------------------------

 ------ -----------------------------------
  Line   app/Models/Subscription.php
 ------ -----------------------------------
  111    Undefined variable: $component_id
 ------ -----------------------------------

 ------ --------------------------------------------------------
  Line   app/Notifications/Incident/NewIncidentNotification.php
 ------ --------------------------------------------------------
  130    Anonymous function has an unused use $notifiable.
 ------ --------------------------------------------------------

 ------ ------------------------------------------------------------------
  Line   app/Notifications/IncidentUpdate/IncidentUpdatedNotification.php
 ------ ------------------------------------------------------------------
  137    Anonymous function has an unused use $content.
 ------ ------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------
  Line   app/Presenters/IncidentPresenter.php
 ------ ------------------------------------------------------------------------------------------------------
  60     Constructor of class CachetHQ\Cachet\Presenters\IncidentPresenter has an unused parameter $resource.
 ------ ------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------
  Line   app/Presenters/SchedulePresenter.php
 ------ ------------------------------------------------------------------------------------------------------
  45     Constructor of class CachetHQ\Cachet\Presenters\SchedulePresenter has an unused parameter $resource.
 ------ ------------------------------------------------------------------------------------------------------


 [ERROR] Found 42 errors

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Sep 7, 2019

A livable Level - like 4 - says Found 304 errors

@diegosouza
Copy link
Contributor

Ok. I've seen your profile and it seems you're active and not a beginner.

What's the point? Would you like to receive and "OK" from a core dev for you suggestion?
We can work together. Would you like to split some tasks?

@szepeviktor
Copy link
Contributor Author

What's the point?

TBH In a project without static analysis it is barely possible to avoid hard bugs.

I think I'm not able to work on Cachet as I'm not even a user. I've opened issues similar to this in ~50 projects.

@jbrooksuk
Copy link
Member

Thanks! I'd like to rewrite a large portion of the code at some point. We now have things like Resources which we didn't have before, so we used Model Presenters, which are abused and make things complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants