あまり詳しくないのでおしえてください! 気になるところがあったらどんどん止めて。 あと、こんなことやってるので誰か手伝って!
今使ってる lintなど静的解析のコマンド、web サービスなど
- PHP CodeSniffer
- CodeSniffer is a tool which checks if your code is compliant with a general ruleset or your own custom ruleset.
- PHP MD
- MD stands for Mess Detector
- php
- 知りたい
- javascript
- eslint, jscsなどがある
- これらを使っているプロジェクトの場合、そもそもこれらが
npm test
の中などに組み込んであることが多い - gulpでwatchしてたりして、手元で保存して怒られて直す
- 静的解析とかASTいじるとかtranspilerとか全盛
- 片手間javascriptの場合、viewにjavascript片が うわー
- golang
- gofmt, gorename など? golint 全然知らない
- python
- pep8, flake8
- ruby
- rubocop, brakeman, ruby組み込みのcheck warning などがある
- test には組み込んでいないところが多い testはtestのみ
- HoundCI, pronto といったソリューション(pull requestにreview commentとして載せる)
エディタなりIDEなりの手元でガンガン支援受けて直すのが一番いい
- phpstorm
- vim
- emacs
全員がlint済みのものをpushしてくれるか? というと疑問 低い方に合わせる jenkinsのログに、カバレッジと一緒に眠ってるよ 必要無いならそれでいい、無駄に可視化すると埋もれる
おもにrubyプロジェクトの場合 HoundCI, pronto 言語ごとに実装してるのマヌケっぽい
# TravisCIやCircleCIの after testの中で(travisCI用語でafter_script, CircleCI用語でpost test)
git diff --name-only origin/master \
| grep ".*.php$" \
| xargs phpcs --report=checkstyle \
| checkstyle_filter-git diff origin/master \
| saddler report \
--require saddler/reporter/github \
--reporter Saddler::Reporter::Github::PullRequestReviewComment
途中出力
git diff --name-only origin/master \
| grep ".*.php$" \
| xargs phpcs --report=checkstyle
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.0.0">
<file name="/path/to/code/myfile.php">
<error line="2" column="1" severity="error" message="Missing file doc comment" source="PEAR.Commenting.FileComment"/>
<error line="20" column="43" severity="error" message="PHP keywords must be lowercase; expected "false" but found "FALSE"" source="Generic.PHP.LowerCaseConstant"/>
<error line="47" column="1" severity="error" message="Line not indented correctly; expected 4 spaces but found 1" source="PEAR.WhiteSpace.ScopeIndent"/>
<error line="47" column="20" severity="warning" message="Equals sign not aligned with surrounding assignments" source="Generic.Formatting.MultipleStatementAlignment"/>
<error line="51" column="4" severity="error" message="Missing function doc comment" source="PEAR.Commenting.FunctionComment"/>
</file>
</checkstyle>
と、たぶんなるはずなんだけど、手元にいい感じにsetupしたphpプロジェクト無いので、誰か手伝ってほしい。