laravel-fans / laravel-lint Goto Github PK
View Code? Open in Web Editor NEWCheck Code Style(default PSR-12) for Laravel
Home Page: https://packagist.org/packages/laravel-fans/lint
License: MIT License
Check Code Style(default PSR-12) for Laravel
Home Page: https://packagist.org/packages/laravel-fans/lint
License: MIT License
laravel-8$ git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: .dockerignore
new file: Dockerfile
modified: composer.json
modified: composer.lock
new file: docker/etc/apache2/sites-available/laravel.conf
new file: docker/usr/local/bin/docker-laravel-entrypoint
new file: docker/var/spool/cron/crontabs/root
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
laravel-8$ git commit -m 'feat: docker'
ERROR: You must supply at least one file or directory to process.
Run "phpcs --help" for usage information
https://github.com/laravel-fans/laravel-lint/runs/1077966301?check_suite_focus=true
There was 1 failure:
/__w/laravel-lint/laravel-lint/tests/LintPublishCommandTest.php:12
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
Generating code coverage report in Clover XML format ... done [00:00.003]
##[error]Process completed with exit code 1.
Laravel 文件名有规范,需要检查,防止有人提交 User_Controller.php
$ tree app/
app/
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── API
│ │ │ ├── SanctumController.php
│ │ │ ├── TaskController.php
$ tree routes/
routes/
├── api.php
├── channels.php
├── console.php
└── web.php
$ tree database/
database/
├── factories
│ ├── SocialAccountFactory.php
│ ├── TaskFactory.php
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
└── seeders
└── DatabaseSeeder.php
https://github.com/laravel-fans/laravel-lint/runs/1484499814?check_suite_focus=true
after install xdebug in PHP docker, phpunit can't generate coverage report.
$ docker run -it php:8.0-cli bash
$ pecl install xdebug
$ docker-php-ext-enable xdebug
$ ./vendor/bin/phpunit --coverage-text --coverage-filter src/ tests/
PHPUnit 9.3.8 by Sebastian Bergmann and contributors.
Warning: XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set
.... 4 / 4 (100%)
Time: 00:01.575, Memory: 18.00 MB
OK (4 tests, 8 assertions)
phpmd can scan something which phpcs can not find. such as:
The class Foo has 11 public methods. Consider refactoring Foo to keep number of public methods under 10.
The method foo() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
刚测试 #21 ,执行
php artisan lint:code database/
发现没效果,看代码发现只执行了 phpcs,而没执行 phpmd:
laravel-lint/src/LintCodeCommand.php
Line 35 in 9a52b07
上次增加了路由检查
php artisan lint:route
之前的
php artisan lint:check app/ tests/
产生了歧义,考虑改成
php artisan lint:code app/ tests/
最后的目录也考虑干掉
很多程序员不懂得 SLUG URL 规范,导致路由出现了下划线、大写,需要进行检查,而且应该是默认命令就检查。
不要支持 Windows,应检测系统,禁止执行,提示使用 WSL
微软都不搞 PHP 8.0 了,主推 WSL
phpcs 自带了修复功能,需要在 lint 命令里支持,参考:
$ php artisan lint:check .
FILE: /Volumes/Code/laravel-fans/laravel-7/tests/TestCase.php
---------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------
8 | ERROR | [x] Opening class brace must be on a line by itself
8 | ERROR | [x] The first trait import statement must be declared on the first non-comment line after
| | the class opening brace
---------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.