Tệp cấu hình PHPMD

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

Cá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"
0

linter:
phpmd:
target:
- index.php
- wp-content/
Bản sao

cấ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"
9

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"
Bản sao

Bạn có thể sử dụng một số tùy chọn để tinh chỉnh PHPMD cho dự án của mình

NameTypeDefault
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
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"
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"
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"
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
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"
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"
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"
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"
7
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-
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
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"
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"
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"
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"
9
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
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"
71

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

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ụ

Trình phát hiện lộn xộn PHP là gì?

Sửa đổi lần cuối. 01 Tháng tám 2022. Ngoài hỗ trợ viết mã tích hợp, PhpStorm cung cấp khả năng kiểm tra mã nguồn thông qua tích hợp với công cụ PHP Mess Detector, giúp phát hiện các vấn đề tiềm ẩn liên quan đến kích thước mã, tính không nhất quán, mã không sử dụng, vi phạm đặt tên . .

PHP md là gì?

PHPMD là một dự án phụ của PHP Depend và nhằm mục đích trở thành một PHP tương đương với công cụ Java nổi tiếng PMD . PHPMD có thể được coi là một ứng dụng lối vào thân thiện với người dùng cho luồng số liệu thô được đo bằng PHP Depend. https. //phpmd. tổ chức.

Chủ Đề