PHPMD là một công cụ phân tích tĩnh tập trung vào việc phát hiện mã có mùi và các lỗi có thể xảy ra trong mã PHP của bạn
Bắt đầu
Để bắt đầu sử dụng PHPMD, hãy kích hoạt nó trong cài đặt kho lưu trữ của bạn
Cấu hình mặc định cho PHPMD
Sider cung cấp bộ quy tắc được đề xuất của chúng tôi cho PHPMD. Cấu hình này được sử dụng khi tùy chọn
linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
8 không được chỉ định trong linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
9 trong kho lưu trữ của bạn. Để biết thêm chi tiết, vui lòng truy cập Bộ quy tắc được đề xuấtCác vấn đề về hiệu suất
PHPMD đôi khi tăng thời gian chờ phân tích với cơ sở mã lớn hơn
Để giảm thiểu điều này, Sider xóa các tệp không bị thay đổi trong yêu cầu kéo. Hành vi này được thực hiện tự động và không thể bị vô hiệu hóa
Nếu PHPMD vẫn tăng thời gian chờ, bạn có thể giảm các tệp mục tiêu của phân tích PHPMD bằng cách sử dụng tùy chọn
linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
0linter:
phpmd:
target:
- index.php
- wp-content/
Bản saocấu hình
Đây là một cấu hình ví dụ thông qua
linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
9linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
Bản saoBạn có thể sử dụng một số tùy chọn để tinh chỉnh PHPMD cho dự án của mình
NameTypeDefaultlinter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3-linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
0linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3, linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
8linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3, linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2[xem bên dưới]linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
7linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
8-linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
9linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3, linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2# sider.yml
linter:
phpmd:
rule: custom_ruleset.xml
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2# sider.yml
linter:
phpmd:
rule: custom_ruleset.xml
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
3, linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2-# sider.yml
linter:
phpmd:
rule: custom_ruleset.xml
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
6# sider.yml
linter:
phpmd:
rule: custom_ruleset.xml
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
7# sider.yml
linter:
phpmd:
rule: custom_ruleset.xml
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
8# sider.yml
linter:
phpmd:
rule: custom_ruleset.xml
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
9linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
2linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
71Xem thêm tài liệu PHPMD để biết chi tiết
linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
0
linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
Tùy chọn này cho phép bạn chỉ định đường dẫn tệp PHP quy tắc tùy chỉnh của riêng bạn. Mô hình quả cầu cũng có sẵn. Bạn cần sử dụng nó cùng với tùy chọn
linter:
phpmd:
target:
- index.php
- wp-content/
rule:
- codesize
- unusedcode
- my_custom_ruleset.xml
minimumpriority: 3
suffixes: [php, phtml]
exclude:
- app/vendor/
- "test/*.php"
strict: true
custom_rule_path:
- Custom_PHPMD_Rule.php
- "custom/phpmd/rules/**/*.php"
8. Ví dụ