silverstripe/moduleratings-plugin

一个Composer插件,提供对本地模块进行评分的能力

0.2.0 2020-11-18 04:14 UTC

This package is auto-updated.

Last update: 2024-09-18 12:59:52 UTC


README

Scrutinizer Code Quality

此软件包提供了一个Composer插件,该插件使SilverStripe模块评分包的功能可以通过Composer在命令行中使用。

安装

使用Composer安装

composer require silverstripe/moduleratings-plugin

用法

安装完成后,您将看到一个新的rate-module命令。与其他Composer(和Symfony控制台)命令一样,您可以在命令中添加--help以查看关于其功能以及如何使用和操作它的信息。

$ composer rate-module --help

Usage:
  rate-module [options] [--] <module-path>

Arguments:
  module-path                    The path to the module folder, relative to the current working directory

Options:
      --slug[=SLUG]              The module's GitHub repository slug, e.g. silverstripe/silverstripe-blog - used for API checks
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  This command will assess the provided module based on a selection of pre-defined quality checks, and provide a rating
  out of 100.
  
  You must provide the module-path to map the path from the current working directory to the source code
  of the module, and you may optionally provide the slug argument which will enable API based status checks.
  
  Note that without providing slug the module will never be able to achieve a 100% score.

如上所述,需要指定模块代码的路径(例如,项目根目录下的vendor/silverstripe/cms)。

--slug参数将允许检查套件运行基于外部API的检查,例如代码覆盖率和Travis构建。这是一个可选的附加功能,但如果不提供它,您将无法达到100%的得分。

示例

要对垃圾邮件防护模块进行评分检查,您可以运行以下命令

$ composer rate-module vendor/silverstripe/spamprotection/ --slug=silverstripe/silverstripe-spamprotection

+---------------------------------------------------------------------------------------+--------+---------+
| Check description                                                                     | Points | Maximum |
+---------------------------------------------------------------------------------------+--------+---------+
| Has a "good" level of code coverage (greater than 40%, requires slug)                 | 5      | 5       |
| Has a "great" level of code coverage (greater than 60%, requires slug)                | 5      | 5       |
| Has a code of conduct file                                                            | 2      | 2       |
| Has source code in either a "code" or a "src" folder                                  | 5      | 5       |
| The PHP code in this module passes the SilverStripe lint rules (mostly PSR-2)         | 10     | 10      |
| Has a contributing guide file                                                         | 0      | 2       |
| Has a .editorconfig file                                                              | 5      | 5       |
| Has a .gitattributes file                                                             | 2      | 2       |
| Has a license file                                                                    | 5      | 5       |
| Has a readme file                                                                     | 5      | 5       |
| Has Scrutinizer CI configured and a "good" score (greater than 6.5/10, requires slug) | 10     | 10      |
| Has Travis CI configured and the last build passed successfully (requires slug)       | 10     | 10      |
+---------------------------------------------------------------------------------------+--------+---------+
| TOTAL SCORE (normalised)                                                              | 97     | 100     |
+---------------------------------------------------------------------------------------+--------+---------+

在上面的示例中,您将看到每个检查的结果,包括为满足检查标准而获得的分数,以及如果检查成功可以获得的最大潜在分数。

总分以百分比的形式给出,例如本例中的97%。请注意,结果是经过归一化的,因此是97/100而不是64/66(如果您将每个检查结果相加)。

有关检查的更多信息

有关检查套件的更多信息,请参阅模块评分包