2017 © Pedro Peláez
 

library moduleratings

A library to provide module code quality ratings

image

silverstripe/moduleratings

A library to provide module code quality ratings

  • Friday, July 13, 2018
  • by robbieaverill
  • Repository
  • 5 Watchers
  • 1 Stars
  • 214 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 10 Versions
  • 44 % Grown

The README.md

SilverStripe module ratings

Build Status Scrutinizer Code Quality codecov, (*1)

This module provides a check suite, and a set of automated checks that can be run over a SilverStripe module to determine a "quality rating"., (*2)

This library can be installed into a SilverStripe 3 or 4 project that uses Composer., (*3)

Installation

You can install this library with Composer if you want to use its public API:, (*4)

composer require silverstripe/moduleratings

You can also install the silverstripe/moduleratings-plugin Composer plugin, which will provide a Composer command you can run locally to check module quality ratings. Please see the readme in that module for more information on using it., (*5)

Requirements

Note: If you have conflicts with any of the symfony components (if using the Composer plugin) during installation, you may need to manually require an older version of one or both of those packages, e.g.:, (*6)

composer require symfony/yaml ~3.0
composer require symfony/console ~3.0

Using the API

To create a check suite, use the SilverStripe\ModuleRatings\CheckSuite class. You will need to provide the directory path to the module code you want to check, and optionally the GitHub repository slug for the module (note: only GitHub supported at this stage). Providing the repository slug will enable checks that look at external continuous integration system APIs to determine quality metrics (e.g. Travis, Scrutinizer)., (*7)

$checkSuite = new \SilverStripe\ModuleRatings\CheckSuite();

$checkSuite
    ->setModuleRoot('/path/to/silverstripe/framework')
    ->setRepositorySlug('silverstripe/silverstripe-framework');

$checkSuite->run();

echo 'Framework has scored ' . $checkSuite->getScore() . ' out of 100 points. Details:', PHP_EOL;
print_r($checkSuite->getCheckDetails());

The return data from CheckSuite::getCheckDetails is an array with the following example structure (note that example is JSON encoded):, (*8)

{
  "good_code_coverage": {
    "description": "Has a \"good\" level of code coverage (greater than 40%, requires slug)",
    "points": 5,
    "maximum": 5
  },
  "has_code_of_conduct_file": {
    "description": "Has a code of conduct file",
    "points": 2,
    "maximum": 2
  },
  "coding_standards": {
    "description": "The PHP code in this module passes the SilverStripe lint rules (mostly PSR-2)",
    "points": 0,
    "maximum": 10
  }
 }

Available checks

  • "Good" code coverage (>= 40%) (via either Scrutinizer CI or Codecov.io)
  • "Great" code coverage (>= 75%) (via either Scrutinizer CI or Codecov.io)
  • PHP code is in either "code" or "src" folder
  • PHP code passes a PSR-2-ish linting standards check (phpcs.xml.dist is stored in src/Check/CodingStandardCheck for reference)
  • Contributing guide file exists
  • Has documentation
  • EditorConfig configuration file exists
  • .gitattributes file exists
  • A license file exists
  • The repository has a readme
  • Scrutinizer CI is configured and has a "good" quality rating (>= 6.5/10)
  • One of either Travis CI or CircleCI is configured and the last build passed successfully

The registered checks are defined in config.yml along with the number of points awarded for each check given that it passes., (*9)

Caveats

Please note the following caveats/gotchas/todos:, (*10)

  • Code repositories must exist on GitHub for external API checks to work

Thanks!

A huge thank you to Chris Pitt who originally wrote Helpful Robot, the inspiration for this library., (*11)

The checks in this library are heavily inspired by the original Helpful Robot checks, and are designed to match the SilverStripe commercially supported module standard., (*12)

Without Helpful Robot the SilverStripe community would look a lot less tidy today!, (*13)

The Versions

13/07 2018

dev-master

9999999-dev

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

13/07 2018

1.0.1

1.0.1.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

10/05 2018

0.5.0

0.5.0.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

10/05 2018

1.0.0

1.0.0.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

04/04 2018

0.4.2

0.4.2.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

17/02 2018

0.4.1

0.4.1.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

16/02 2018

0.4.0

0.4.0.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

15/02 2018

0.3.0

0.3.0.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

15/02 2018

0.2.0

0.2.0.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill

20/12 2017

0.1.0

0.1.0.0

A library to provide module code quality ratings

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Robbie Averill