Comments Density
v0.3.0
一種工具來分析PHP源代碼文件中的註釋密度和質量,從而幫助維護和改善代碼文檔質量。

要安裝評論密度分析儀,請在終端中運行以下命令:
composer require --dev savinmikhail/comments-density通過以下方式分析您的PHP文件中的評論密度
php vendor/bin/comments_density analyze:comments生成基線:
php vendor/bin/comments_density generate:baseline安裝時,您可以允許插件創建其配置文件。通過編輯comment_dense.php配置文件來自定義分析:
<?php
return [
' directories ' => [
' src ' , // Directories to be scanned for comments
],
' exclude ' => [
' src/DTO ' , // Directories to be ignored during scanning
],
' thresholds ' => [
// Limit occurrences of each comment type
' docBlock ' => 90 ,
' regular ' => 5 ,
' todo ' => 5 ,
' fixme ' => 5 ,
' missingDocBlock ' => 10 ,
// Additional metrics thresholds
' Com/LoC ' => 0.1 , // Comments per Lines of Code
' CDS ' => 0.1 , // Comment Density Score
],
' only ' => [
' missingDocblock ' , // Only this type will be analyzed; set to empty array for full statistics
],
' output ' => [
' type ' => ' console ' , // Supported values: 'console', 'html'
' file ' => ' output.html ' , // File path for HTML output (only used if type is 'html')
],
' missingDocblock ' => [
' class ' => true , // Check for missing docblocks in classes
' interface ' => true , // Check for missing docblocks in interfaces
' trait ' => true , // Check for missing docblocks in traits
' enum ' => true , // Check for missing docblocks in enums
' property ' => true , // Check for missing docblocks in properties
' constant ' => true , // Check for missing docblocks in constants
' function ' => true , // Check for missing docblocks in functions
' requireForAllMethods ' => true , // If false, only methods where @throws tag or generic can be applied will be checked
],
' use_baseline ' => true , // Filter collected comments against the baseline stored in comments_density.sqlite
];該項目的靈感來自Yegor Bugayenko。請參閱Opensource的想法。
歡迎捐款!請隨時提交拉動請求。
該庫是根據麻省理工學院許可證發布的。