Check also tasks and tools with code sniffer

[MAILPOET-2429]
This commit is contained in:
Jan Jakeš
2019-10-10 13:39:12 +02:00
committed by Jack Kitterhing
parent cc62da6cb3
commit 7ecabdba3a
14 changed files with 88 additions and 64 deletions

View File

@ -7,6 +7,7 @@ if (!file_exists($path)) {
$filename = $path . '/mailpoet-' . microtime(true) . '.txt';
$file_handle = fopen($filename, "w");
// phpcs:ignore Squiz.PHP.DiscouragedFunctions
$call_arguments = print_r($argv, true) . "\n";
fwrite($file_handle, $call_arguments);

View File

@ -383,7 +383,24 @@ class RoboFile extends \Robo\Tasks {
->taskExec($task)
->rawArg('--runtime-set testVersion 5.6-7.3')
->rawArg('-l .')
// PHP >= 7.2 for dev tools, etc.
->taskExec($task)
->rawArg('--runtime-set testVersion 7.2-7.3')
->arg('--ignore=' . implode(',', [
'prefixer/build',
'prefixer/vendor',
'tasks/code_sniffer/vendor',
'tasks/makepot',
'tools/vendor',
])
)
->args([
'.circleci',
'prefixer',
'tasks',
'tools',
])
->run();
}

View File

@ -44,7 +44,7 @@ $replacements = [
[
'file' => '../vendor-prefixed/twig/twig/src/Node/Expression/Binary/NotInBinary.php',
'find' => [
'\'!twig_in_filter(\''
'\'!twig_in_filter(\'',
],
'replace' => [
'\'!\\\\MailPoetVendor\\\\twig_in_filter(\'',
@ -53,7 +53,7 @@ $replacements = [
[
'file' => '../vendor-prefixed/twig/twig/src/Node/Expression/Binary/InBinary.php',
'find' => [
'\'twig_in_filter(\''
'\'twig_in_filter(\'',
],
'replace' => [
'\'\\\\MailPoetVendor\\\\twig_in_filter(\'',

View File

@ -18,7 +18,7 @@ return [
'vendor-bin',
'composer',
])
->in('vendor')
->in('vendor'),
],
// Whitelists a list of files. Unlike the other whitelist related features, this one is about completely leaving

View File

@ -1,4 +1,7 @@
<?php
namespace MailPoet\Sniffs;
/**
* Verifies spacing of control statements.
*
@ -14,7 +17,7 @@
*/
if (class_exists('PHP_CodeSniffer\Sniffs\AbstractPatternSniff', true) === false) {
throw new \PHP_CodeSniffer\Exceptions\RuntimeException('Class PHP_CodeSniffer\Sniffs\AbstractPatternSniff not found');
throw new \PHP_CodeSniffer\Exceptions\RuntimeException('Class PHP_CodeSniffer\Sniffs\AbstractPatternSniff not found');
}
/**
@ -29,33 +32,33 @@ if (class_exists('PHP_CodeSniffer\Sniffs\AbstractPatternSniff', true) === false)
* @version Release: @package_version@
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class MailPoet_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer\Sniffs\AbstractPatternSniff {
class ControlSignatureSniff extends \PHP_CodeSniffer\Sniffs\AbstractPatternSniff {
/**
* If true, comments will be ignored if they are found in the code.
*
* @var boolean
*/
public $ignoreComments = true;
/**
* If true, comments will be ignored if they are found in the code.
*
* @var boolean
*/
public $ignoreComments = true;
/**
* Returns the patterns that this test wishes to verify.
*
* @return string[]
*/
protected function getPatterns() {
return array(
'do {EOL...} while (...);EOL',
'while (...) {EOL',
'for (...) {EOL',
'if (...) {EOL',
'foreach (...) {EOL',
'} else if (...) {EOL',
'} elseif (...) {EOL',
'} else {EOL',
'do {EOL',
'switch (...) {EOL',
'catch (...) {EOL',
);
}
/**
* Returns the patterns that this test wishes to verify.
*
* @return string[]
*/
protected function getPatterns() {
return [
'do {EOL...} while (...);EOL',
'while (...) {EOL',
'for (...) {EOL',
'if (...) {EOL',
'foreach (...) {EOL',
'} else if (...) {EOL',
'} elseif (...) {EOL',
'} else {EOL',
'do {EOL',
'switch (...) {EOL',
'catch (...) {EOL',
];
}
}

View File

@ -18,7 +18,7 @@ if (count($argv) !== 2) {
}
// absolutize path (if not absolute)
$directory = rtrim($argv[1]. '/');
$directory = rtrim($argv[1] . '/');
if (mb_substr($directory, 0, 1) !== DIRECTORY_SEPARATOR) {
$directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
}

View File

@ -5,16 +5,14 @@ namespace MailPoet\Premium\DI;
use MailPoet\DI\IContainerConfigurator;
use MailPoetVendor\Symfony\Component\DependencyInjection\ContainerBuilder;
class ContainerConfigurator implements IContainerConfigurator{
function configure(ContainerBuilder $container)
{
// phpcs:ignore Squiz.Classes.ClassFileName
class ContainerConfigurator implements IContainerConfigurator {
function configure(ContainerBuilder $container) {
}
function getDumpNamespace()
{
function getDumpNamespace() {
}
function getDumpClassname()
{
function getDumpClassname() {
}
}

View File

@ -5,7 +5,8 @@ define('ABSPATH', getenv('WP_ROOT') . '/');
require_once ABSPATH . 'wp-load.php';
require_once ABSPATH . 'wp-admin/includes/admin.php';
require_once ABSPATH . '/wp-includes/class-phpmailer.php';
if(!class_exists('\MailPoet\Premium\DI\ContainerConfigurator')) {
if (!class_exists('\MailPoet\Premium\DI\ContainerConfigurator')) {
require_once './PremiumContainerConfigurator.php';
}

View File

@ -1,14 +1,17 @@
<?php
class WooCommerce {}
// phpcs:ignore
class WooCommerce {
}
/**
* @return WooCommerce
*/
function WC() {}
function WC() {
}
function wc_get_customer_order_count(int $user_id): int {
return 0;
return 0;
}
/**
@ -16,7 +19,7 @@ return 0;
* @return mixed
*/
function wc_get_order($order = false) {
return false;
return false;
}
/**
@ -24,25 +27,27 @@ return false;
* @return WC_Order[]|int[]|\stdClass
*/
function wc_get_orders($args) {
return [];
return [];
}
function wc_price(float $price, array $args = []): string {
return '';
return '';
}
/**
* @return string
*/
function get_woocommerce_currency() {
return '';
return '';
}
function wc_get_product($the_product = false, $deprecated = array()) {
return null;
function wc_get_product($the_product = false, $deprecated = []) {
return null;
}
class WC_DateTime extends \DateTime {}
// phpcs:ignore
class WC_DateTime extends \DateTime {
}
/**
* @method int get_id()
@ -51,4 +56,5 @@ class WC_DateTime extends \DateTime {}
* @method string get_currency(string $context = 'view')
* @method float get_total(string $context = 'view')
*/
class WC_Order {}
class WC_Order { // phpcs:ignore
}

View File

@ -38,7 +38,7 @@ class ChangelogController {
private function renderHeading(array $version) {
$date = empty($version['releaseDate']) ? date('Y-m-d') : $version['releaseDate'];
return "= {$version['name']}" . self::HEADING_GLUE . "$date =";
return "= {$version['name']}" . self::HEADING_GLUE . "$date =";
}
private function renderList(array $issues, $field) {

View File

@ -66,7 +66,7 @@ class GitHubController {
'head' => self::RELEASE_SOURCE_BRANCH,
'base' => 'master',
'direction' => 'desc',
]
],
]);
$response = json_decode($response->getBody()->getContents(), true);
if (sizeof($response) === 0) {
@ -182,11 +182,10 @@ class GitHubController {
return json_decode($response->getBody()->getContents(), true);
}
private function uploadReleaseZip($upload_url, $release_zip_path)
{
private function uploadReleaseZip($upload_url, $release_zip_path) {
$this->http_client->post($upload_url, [
'headers' => [
'Content-Type' => 'application/zip'
'Content-Type' => 'application/zip',
],
'query' => [
'name' => $this->zip_filename,
@ -195,8 +194,7 @@ class GitHubController {
]);
}
private function publishDraftAsRelease($release_id)
{
private function publishDraftAsRelease($release_id) {
$this->http_client->patch('releases/' . urlencode($release_id), [
'json' => [
'draft' => false,

View File

@ -66,7 +66,7 @@ class JiraController {
'query' => [
'maxResults' => 1,
'orderBy' => '-sequence',
]
],
]);
$version = json_decode($response->getBody()->getContents(), true);
if (empty($version) || empty($version['values'])) {
@ -81,7 +81,7 @@ class JiraController {
'maxResults' => 1,
'orderBy' => '-sequence',
'status' => 'released',
]
],
]);
$version = json_decode($response->getBody()->getContents(), true);
if (empty($version) || empty($version['values'])) {

View File

@ -97,9 +97,9 @@ class ReleaseVersionController {
$data = [
'update' => [
'fixVersions' => [
['set' => [['name' => $version]]]
]
]
['set' => [['name' => $version]]],
],
],
];
return $this->jira->updateIssue($issue_key, $data);
}

View File

@ -8,7 +8,7 @@ $tools = [
];
// ensure installation in dev-mode only
$is_dev_mode = (bool) getenv('COMPOSER_DEV_MODE');
$is_dev_mode = (bool)getenv('COMPOSER_DEV_MODE');
if (!$is_dev_mode) {
fwrite(STDERR, "Skipping installing dev tools in non-dev mode.\n");
return;