Giter Club home page Giter Club logo

laravel-lint's People

Contributors

hms5232 avatar phuthuycoding avatar sinkcup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-lint's Issues

ERROR: You must supply at least one file

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

CI failed

https://github.com/laravel-fans/laravel-lint/runs/1077966301?check_suite_focus=true

There was 1 failure:

  1. LaravelFans\Lint\Tests\LintPublishCommandTest::testHandle
    Failed asserting that file "/__w/laravel-lint/laravel-lint/tests/../vendor/orchestra/testbench-core/laravel/.git/hooks/pre-commit" exists.

/__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.

路径 和 文件名 lint

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

Warning: xdebug.mode=coverage has to be set

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)

phpcs is not enough, phpmd is more powerful

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.

优化命令命名

上次增加了路由检查

php artisan lint:route

之前的

php artisan lint:check app/ tests/

产生了歧义,考虑改成

php artisan lint:code app/ tests/

最后的目录也考虑干掉

lint URL

很多程序员不懂得 SLUG URL 规范,导致路由出现了下划线、大写,需要进行检查,而且应该是默认命令就检查。

支持自动修复

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
---------------------------------------------------------------------------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.