Code style fixes for plugins.

This commit is contained in:
Dmitry Khomutov 2018-02-04 14:22:07 +07:00
parent 16755eadd4
commit 5e9e3088cc
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
20 changed files with 167 additions and 163 deletions

View file

@ -16,11 +16,17 @@
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable"/>
<exclude name="ShortMethodName"/>
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="exceptions" value="db,id,i,j" />
<property name="exceptions" value="db,dn,id,i,j" />
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortMethodName">
<properties>
<property name="exceptions" value="up" />
</properties>
</rule>
</ruleset>

View file

@ -11,7 +11,7 @@ use PHPCensor\Model\User;
/**
* Project Controller - Allows users to create, edit and view projects.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class GroupController extends Controller
@ -46,7 +46,7 @@ class GroupController extends Controller
];
$projects_active = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), false);
$projects_archived = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), true);
$thisGroup['projects'] = array_merge($projects_active['items'], $projects_archived['items']);
$groups[] = $thisGroup;
}

View file

@ -647,30 +647,30 @@ class WebhookController extends Controller
*/
protected function gogsPullRequest(Project $project, array $payload)
{
$pull_request = $payload['pull_request'];
$head_branch = $pull_request['head_branch'];
$pullRequest = $payload['pull_request'];
$headBranch = $pullRequest['head_branch'];
$action = $payload['action'];
$active_actions = ['opened', 'reopened', 'label_updated', 'label_cleared'];
$inactive_actions = ['closed'];
$action = $payload['action'];
$activeActions = ['opened', 'reopened', 'label_updated', 'label_cleared'];
$inactiveActions = ['closed'];
$state = $pull_request['state'];
$active_states = ['open'];
$inactive_states = ['closed'];
$state = $pullRequest['state'];
$activeStates = ['open'];
$inactiveStates = ['closed'];
if (!in_array($action, $active_actions) and !in_array($action, $inactive_actions)) {
if (!in_array($action, $activeActions) and !in_array($action, $inactiveActions)) {
return ['status' => 'ignored', 'message' => 'Action ' . $action . ' ignored'];
}
if (!in_array($state, $active_states) and !in_array($state, $inactive_states)) {
if (!in_array($state, $activeStates) and !in_array($state, $inactiveStates)) {
return ['status' => 'ignored', 'message' => 'State ' . $state . ' ignored'];
}
$envs = [];
// Get environment form labels
if (in_array($action, $active_actions) and in_array($state, $active_states)) {
if (isset($pull_request['labels']) && is_array($pull_request['labels'])) {
foreach ($pull_request['labels'] as $label) {
if (in_array($action, $activeActions) and in_array($state, $activeStates)) {
if (isset($pullRequest['labels']) && is_array($pullRequest['labels'])) {
foreach ($pullRequest['labels'] as $label) {
if (strpos($label['name'], 'env:') === 0) {
$envs[] = substr($label['name'], 4);
}
@ -678,42 +678,42 @@ class WebhookController extends Controller
}
}
$envs_updated = [];
$env_objs = $project->getEnvironmentsObjects();
$store = Factory::getStore('Environment', 'PHPCensor');;
foreach ($env_objs['items'] as $environment) {
$envsUpdated = [];
$envObjects = $project->getEnvironmentsObjects();
$store = Factory::getStore('Environment', 'PHPCensor');
foreach ($envObjects['items'] as $environment) {
$branches = $environment->getBranches();
if (in_array($environment->getName(), $envs)) {
if (!in_array($head_branch, $branches)) {
if (!in_array($headBranch, $branches)) {
// Add branch to environment
$branches[] = $head_branch;
$branches[] = $headBranch;
$environment->setBranches($branches);
$store->save($environment);
$envs_updated[] = $environment->getName();
$envsUpdated[] = $environment->getName();
}
} else {
if (in_array($head_branch, $branches)) {
if (in_array($headBranch, $branches)) {
// Remove branch from environment
$branches = array_diff($branches, [$head_branch]);
$branches = array_diff($branches, [$headBranch]);
$environment->setBranches($branches);
$store->save($environment);
$envs_updated[] = $environment->getName();
$envsUpdated[] = $environment->getName();
}
}
}
if (($state == 'closed') and $pull_request['merged']) {
// update base branch enviroments
$environment_names = $project->getEnvironmentsNamesByBranch($pull_request['base_branch']);
$envs_updated = array_merge($envs_updated, $environment_names);
if (($state == 'closed') and $pullRequest['merged']) {
// update base branch environments
$environmentNames = $project->getEnvironmentsNamesByBranch($pullRequest['base_branch']);
$envsUpdated = array_merge($envsUpdated, $environmentNames);
}
$envs_updated = array_unique($envs_updated);
if (!empty($envs_updated)) {
foreach ($envs_updated as $environment_name) {
$envsUpdated = array_unique($envsUpdated);
if (!empty($envsUpdated)) {
foreach ($envsUpdated as $environmentName) {
$this->buildService->createBuild(
$project,
$environment_name,
$environmentName,
'',
$project->getBranch(),
null,
@ -725,7 +725,7 @@ class WebhookController extends Controller
);
}
return ['status' => 'ok', 'message' => 'Branch environments updated ' . join(', ', $envs_updated)];
return ['status' => 'ok', 'message' => 'Branch environments updated ' . join(', ', $envsUpdated)];
}
return ['status' => 'ignored', 'message' => 'Branch environments not changed'];

View file

@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface;
/**
* Composer Plugin - Provides access to Composer functionality.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class Composer extends Plugin implements ZeroConfigPluginInterface
@ -18,7 +18,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
protected $directory;
protected $action;
protected $preferDist;
protected $nodev;
protected $noDev;
protected $ignorePlatformReqs;
protected $preferSource;
@ -42,7 +42,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
$this->action = 'install';
$this->preferDist = false;
$this->preferSource = false;
$this->nodev = false;
$this->noDev = false;
$this->ignorePlatformReqs = false;
if (array_key_exists('directory', $options)) {
@ -63,7 +63,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
}
if (array_key_exists('no_dev', $options)) {
$this->nodev = (bool)$options['no_dev'];
$this->noDev = (bool)$options['no_dev'];
}
if (array_key_exists('ignore_platform_reqs', $options)) {
@ -107,7 +107,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
$cmd .= ' --prefer-source';
}
if ($this->nodev) {
if ($this->noDev) {
$this->builder->log('Using --no-dev flag');
$cmd .= ' --no-dev';
}

View file

@ -6,13 +6,11 @@ use PHPCensor\Plugin;
/**
* Environment variable plugin
*
*
* @author Steve Kamerman <stevekamerman@gmail.com>
*/
class Env extends Plugin
{
protected $env_vars;
/**
* @return string
*/
@ -20,7 +18,7 @@ class Env extends Plugin
{
return 'env';
}
/**
* Adds the specified environment variables to the builder environment
*/
@ -30,13 +28,13 @@ class Env extends Plugin
foreach ($this->options as $key => $value) {
if (is_numeric($key)) {
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
$env_var = is_array($value)? key($value).'='.current($value): $value;
$envVar = is_array($value)? key($value).'='.current($value): $value;
} else {
// This allows the standard syntax: "FOO: bar"
$env_var = "$key=$value";
$envVar = "$key=$value";
}
if (!putenv($this->builder->interpolate($env_var))) {
if (!putenv($this->builder->interpolate($envVar))) {
$success = false;
$this->builder->logFailure('Unable to set environment variable');
}

View file

@ -10,12 +10,12 @@ use PHPCensor\Plugin;
/**
* Flowdock Plugin
*
*
* @author Petr Cervenka <petr@nanosolutions.io>
*/
class FlowdockNotify extends Plugin
{
protected $api_key;
protected $apiKey;
protected $email;
protected $message;
@ -29,7 +29,7 @@ class FlowdockNotify extends Plugin
{
return 'flowdock_notify';
}
/**
* {@inheritdoc}
*/
@ -40,7 +40,7 @@ class FlowdockNotify extends Plugin
if (!is_array($options) || !isset($options['api_key'])) {
throw new \Exception('Please define the api_key for Flowdock Notify plugin!');
}
$this->api_key = trim($options['api_key']);
$this->apiKey = trim($options['api_key']);
$this->message = isset($options['message']) ? $options['message'] : self::MESSAGE_DEFAULT;
$this->email = isset($options['email']) ? $options['email'] : 'PHP Censor';
}
@ -53,9 +53,9 @@ class FlowdockNotify extends Plugin
public function execute()
{
$message = $this->builder->interpolate($this->message);
$message = $this->builder->interpolate($this->message);
$successfulBuild = $this->build->isSuccessful() ? 'Success' : 'Failed';
$push = new Push($this->api_key);
$push = new Push($this->apiKey);
$flowMessage = TeamInboxMessage::create()
->setSource("PHPCensor")
->setFromAddress($this->email)

View file

@ -12,13 +12,14 @@ use \PHPCensor\Plugin;
/**
* Integrates PHPCensor with Mage: https://github.com/andres-montanez/Magallanes
*
* @package PHPCensor
* @subpackage Plugins
*/
class Mage extends Plugin
{
protected $mage_bin = 'mage';
protected $mage_env;
protected $mageBin = 'mage';
protected $mageEnv;
/**
* {@inheritdoc}
@ -37,11 +38,11 @@ class Mage extends Plugin
$config = $builder->getSystemConfig('mage');
if (!empty($config['bin'])) {
$this->mage_bin = $config['bin'];
$this->mageBin = $config['bin'];
}
if (isset($options['env'])) {
$this->mage_env = $builder->interpolate($options['env']);
$this->mageEnv = $builder->interpolate($options['env']);
}
}
@ -50,12 +51,12 @@ class Mage extends Plugin
*/
public function execute()
{
if (empty($this->mage_env)) {
if (empty($this->mageEnv)) {
$this->builder->logFailure('You must specify environment.');
return false;
}
$result = $this->builder->executeCommand($this->mage_bin . ' deploy to:' . $this->mage_env);
$result = $this->builder->executeCommand($this->mageBin . ' deploy to:' . $this->mageEnv);
try {
$this->builder->log('########## MAGE LOG BEGIN ##########');
@ -75,12 +76,12 @@ class Mage extends Plugin
*/
protected function getMageLog()
{
$logs_dir = $this->build->getBuildPath() . '/.mage/logs';
if (!is_dir($logs_dir)) {
$logsDir = $this->build->getBuildPath() . '/.mage/logs';
if (!is_dir($logsDir)) {
throw new \Exception('Log directory not found');
}
$list = scandir($logs_dir);
$list = scandir($logsDir);
if ($list === false) {
throw new \Exception('Log dir read fail');
}
@ -97,17 +98,17 @@ class Mage extends Plugin
throw new \Exception('Logs sort fail');
}
$last_log_file = end($list);
if ($last_log_file === false) {
$lastLogFile = end($list);
if ($lastLogFile === false) {
throw new \Exception('Get last Log name fail');
}
$log_content = file_get_contents($logs_dir . '/' . $last_log_file);
if ($log_content === false) {
$logContent = file_get_contents($logsDir . '/' . $lastLogFile);
if ($logContent === false) {
throw new \Exception('Get last Log content fail');
}
$lines = explode("\n", $log_content);
$lines = explode("\n", $logContent);
$lines = array_map('trim', $lines);
$lines = array_filter($lines);

View file

@ -12,14 +12,15 @@ use \PHPCensor\Plugin;
/**
* Integrates PHPCensor with Mage v3: https://github.com/andres-montanez/Magallanes
*
* @package PHPCensor
* @subpackage Plugins
*/
class Mage3 extends Plugin
{
protected $mage_bin = 'mage';
protected $mage_env;
protected $mage_log_dir;
protected $mageBin = 'mage';
protected $mageEnv;
protected $mageLogDir;
/**
* {@inheritdoc}
@ -38,15 +39,15 @@ class Mage3 extends Plugin
$config = $builder->getSystemConfig('mage3');
if (!empty($config['bin'])) {
$this->mage_bin = $config['bin'];
$this->mageBin = $config['bin'];
}
if (isset($options['env'])) {
$this->mage_env = $builder->interpolate($options['env']);
$this->mageEnv = $builder->interpolate($options['env']);
}
if (isset($options['log_dir'])) {
$this->mage_log_dir = $builder->interpolate($options['log_dir']);
$this->mageLogDir = $builder->interpolate($options['log_dir']);
}
}
@ -55,12 +56,12 @@ class Mage3 extends Plugin
*/
public function execute()
{
if (empty($this->mage_env)) {
if (empty($this->mageEnv)) {
$this->builder->logFailure('You must specify environment.');
return false;
}
$result = $this->builder->executeCommand($this->mage_bin . ' -n deploy ' . $this->mage_env);
$result = $this->builder->executeCommand($this->mageBin . ' -n deploy ' . $this->mageEnv);
try {
$this->builder->log('########## MAGE LOG BEGIN ##########');
@ -80,12 +81,12 @@ class Mage3 extends Plugin
*/
protected function getMageLog()
{
$logs_dir = $this->build->getBuildPath() . (!empty($this->mage_log_dir) ? '/' . $this->mage_log_dir : '');
if (!is_dir($logs_dir)) {
$logsDir = $this->build->getBuildPath() . (!empty($this->mageLogDir) ? '/' . $this->mageLogDir : '');
if (!is_dir($logsDir)) {
throw new \Exception('Log directory not found');
}
$list = scandir($logs_dir);
$list = scandir($logsDir);
if ($list === false) {
throw new \Exception('Log dir read fail');
}
@ -102,17 +103,17 @@ class Mage3 extends Plugin
throw new \Exception('Logs sort fail');
}
$last_log_file = end($list);
if ($last_log_file === false) {
$lastLogFile = end($list);
if ($lastLogFile === false) {
throw new \Exception('Get last Log name fail');
}
$log_content = file_get_contents($logs_dir . '/' . $last_log_file);
if ($log_content === false) {
$logContent = file_get_contents($logsDir . '/' . $lastLogFile);
if ($logContent === false) {
throw new \Exception('Get last Log content fail');
}
$lines = explode("\n", $log_content);
$lines = explode("\n", $logContent);
$lines = array_map('trim', $lines);
$lines = array_filter($lines);

View file

@ -10,7 +10,7 @@ use b8\Database;
/**
* MySQL Plugin - Provides access to a MySQL database.
*
*
* @author Dan Cryer <dan@block8.co.uk>
* @author Steve Kamerman <stevekamerman@gmail.com>
*/
@ -110,15 +110,15 @@ class Mysql extends Plugin
throw new \Exception('Import statement must contain a \'file\' key');
}
$import_file = $this->builder->buildPath . $this->builder->interpolate($query['file']);
if (!is_readable($import_file)) {
throw new \Exception(sprintf('Cannot open SQL import file: %s', $import_file));
$importFile = $this->builder->buildPath . $this->builder->interpolate($query['file']);
if (!is_readable($importFile)) {
throw new \Exception(sprintf('Cannot open SQL import file: %s', $importFile));
}
$database = isset($query['database']) ? $this->builder->interpolate($query['database']) : null;
$import_command = $this->getImportCommand($import_file, $database);
if (!$this->builder->executeCommand($import_command)) {
$importCommand = $this->getImportCommand($importFile, $database);
if (!$this->builder->executeCommand($importCommand)) {
throw new \Exception('Unable to execute SQL file');
}
@ -140,15 +140,15 @@ class Mysql extends Plugin
'gz' => '| gzip --decompress',
];
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
$decomp_cmd = '';
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
$decompressionCmd = '';
if (array_key_exists($extension, $decompression)) {
$decomp_cmd = $decompression[$extension];
$decompressionCmd = $decompression[$extension];
}
$args = [
':import_file' => escapeshellarg($import_file),
':decomp_cmd' => $decomp_cmd,
':decomp_cmd' => $decompressionCmd,
':host' => escapeshellarg($this->host),
':user' => escapeshellarg($this->user),
':pass' => (!$this->pass) ? '' : '-p' . escapeshellarg($this->pass),

View file

@ -8,7 +8,7 @@ use PHPCensor\Plugin;
/**
* Create a ZIP or TAR.GZ archive of the entire build.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class PackageBuild extends Plugin
@ -24,7 +24,7 @@ class PackageBuild extends Plugin
{
return 'package_build';
}
/**
* {@inheritdoc}
*/
@ -58,7 +58,7 @@ class PackageBuild extends Plugin
$filename = str_replace('%time%', date('Hi'), $filename);
$filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
$curdir = getcwd();
$currentDir = getcwd();
chdir($this->builder->buildPath);
if (!is_array($this->format)) {
@ -79,7 +79,7 @@ class PackageBuild extends Plugin
$success = $this->builder->executeCommand($cmd, $this->directory, $filename);
}
chdir($curdir);
chdir($currentDir);
return $success;
}

View file

@ -26,7 +26,7 @@ class Phing extends Plugin
{
return 'phing';
}
/**
* {@inheritdoc}
*/
@ -106,7 +106,7 @@ class Phing extends Plugin
}
/**
* @return string
* @return array
*/
public function getTargets()
{

View file

@ -11,7 +11,7 @@ use PHPCensor\ZeroConfigPluginInterface;
/**
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
@ -34,7 +34,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
/**
* @var string
*/
protected $tab_width;
protected $tabWidth;
/**
* @var string
@ -44,12 +44,12 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
/**
* @var int
*/
protected $allowed_errors;
protected $allowedErrors;
/**
* @var int
*/
protected $allowed_warnings;
protected $allowedWarnings;
/**
* @var string, based on the assumption the root may not hold the code to be tested, extends the base path
@ -68,12 +68,12 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
/**
* @var null|int
*/
protected $error_severity = null;
protected $errorSeverity = null;
/**
* @var null|int
*/
protected $warning_severity = null;
protected $warningSeverity = null;
/**
* @return string
@ -93,24 +93,24 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
$this->suffixes = ['php'];
$this->directory = $this->builder->buildPath;
$this->standard = 'PSR2';
$this->tab_width = '';
$this->tabWidth = '';
$this->encoding = '';
$this->path = '';
$this->ignore = $this->builder->ignore;
$this->allowed_warnings = 0;
$this->allowed_errors = 0;
$this->allowedWarnings = 0;
$this->allowedErrors = 0;
if (isset($options['zero_config']) && $options['zero_config']) {
$this->allowed_warnings = -1;
$this->allowed_errors = -1;
$this->allowedWarnings = -1;
$this->allowedErrors = -1;
}
if (!empty($options['allowed_errors']) && is_int($options['allowed_errors'])) {
$this->allowed_errors = $options['allowed_errors'];
$this->allowedErrors = $options['allowed_errors'];
}
if (!empty($options['allowed_warnings']) && is_int($options['allowed_warnings'])) {
$this->allowed_warnings = $options['allowed_warnings'];
$this->allowedWarnings = $options['allowed_warnings'];
}
if (isset($options['suffixes'])) {
@ -118,7 +118,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
}
if (!empty($options['tab_width'])) {
$this->tab_width = ' --tab-width='.$options['tab_width'];
$this->tabWidth = ' --tab-width='.$options['tab_width'];
}
if (!empty($options['encoding'])) {
@ -138,11 +138,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
}
if (isset($options['error_severity']) && is_int($options['error_severity'])) {
$this->error_severity = $options['error_severity'];
$this->errorSeverity = $options['error_severity'];
}
if (isset($options['warning_severity']) && is_int($options['warning_severity'])) {
$this->warning_severity = $options['warning_severity'];
$this->warningSeverity = $options['warning_severity'];
}
}
@ -181,7 +181,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
$standard,
$suffixes,
$ignore,
$this->tab_width,
$this->tabWidth,
$this->encoding,
$this->builder->buildPath . $this->path,
$severity,
@ -198,11 +198,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
$this->build->storeMeta('phpcs-warnings', $warnings);
$this->build->storeMeta('phpcs-errors', $errors);
if ($this->allowed_warnings != -1 && $warnings > $this->allowed_warnings) {
if ($this->allowedWarnings != -1 && $warnings > $this->allowedWarnings) {
$success = false;
}
if ($this->allowed_errors != -1 && $errors > $this->allowed_errors) {
if ($this->allowedErrors != -1 && $errors > $this->allowedErrors) {
$success = false;
}
@ -237,13 +237,13 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
}
$errorSeverity = '';
if ($this->error_severity !== null) {
$errorSeverity = ' --error-severity=' . $this->error_severity;
if ($this->errorSeverity !== null) {
$errorSeverity = ' --error-severity=' . $this->errorSeverity;
}
$warningSeverity = '';
if ($this->warning_severity !== null) {
$warningSeverity = ' --warning-severity=' . $this->warning_severity;
if ($this->warningSeverity !== null) {
$warningSeverity = ' --warning-severity=' . $this->warningSeverity;
}
return [$ignore, $standard, $suffixes, $severity, $errorSeverity, $warningSeverity];

View file

@ -11,7 +11,7 @@ use PHPCensor\ZeroConfigPluginInterface;
/**
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
@ -33,7 +33,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
/**
* @var integer
*/
protected $allowed_warnings;
protected $allowedWarnings;
/**
* @return string
@ -42,7 +42,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
{
return 'php_docblock_checker';
}
/**
* {@inheritdoc}
*/
@ -52,10 +52,10 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
$this->ignore = $this->builder->ignore;
$this->path = '';
$this->allowed_warnings = 0;
$this->allowedWarnings = 0;
if (isset($options['zero_config']) && $options['zero_config']) {
$this->allowed_warnings = -1;
$this->allowedWarnings = -1;
}
if (array_key_exists('skip_classes', $options)) {
@ -71,7 +71,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
}
if (array_key_exists('allowed_warnings', $options)) {
$this->allowed_warnings = (int)$options['allowed_warnings'];
$this->allowedWarnings = (int)$options['allowed_warnings'];
}
}
@ -140,7 +140,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
$this->build->storeMeta('phpdoccheck-warnings', $errors);
$this->reportErrors($output);
if ($this->allowed_warnings != -1 && $errors > $this->allowed_warnings) {
if ($this->allowedWarnings != -1 && $errors > $this->allowedWarnings) {
$success = false;
}

View file

@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface;
/**
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
@ -38,7 +38,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
* @var array
*/
protected $rules;
protected $allowed_warnings;
protected $allowedWarnings;
/**
* @return string
@ -59,10 +59,10 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
$this->ignore = $this->builder->ignore;
$this->path = '';
$this->rules = ['codesize', 'unusedcode', 'naming'];
$this->allowed_warnings = 0;
$this->allowedWarnings = 0;
if (isset($options['zero_config']) && $options['zero_config']) {
$this->allowed_warnings = -1;
$this->allowedWarnings = -1;
}
if (!empty($options['path'])) {
@ -70,7 +70,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
}
if (array_key_exists('allowed_warnings', $options)) {
$this->allowed_warnings = (int)$options['allowed_warnings'];
$this->allowedWarnings = (int)$options['allowed_warnings'];
}
foreach (['rules', 'ignore', 'suffixes'] as $key) {
@ -247,7 +247,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
{
$success = true;
if ($this->allowed_warnings != -1 && $errorCount > $this->allowed_warnings) {
if ($this->allowedWarnings != -1 && $errorCount > $this->allowedWarnings) {
$success = false;
return $success;
}

View file

@ -7,7 +7,7 @@ use PHPCensor\Plugin;
/**
* PHP Spec Plugin - Allows PHP Spec testing.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class PhpSpec extends Plugin
@ -25,7 +25,7 @@ class PhpSpec extends Plugin
*/
public function execute()
{
$curdir = getcwd();
$currentDir = getcwd();
chdir($this->builder->buildPath);
$phpspec = $this->findBinary(['phpspec', 'phpspec.php']);
@ -33,7 +33,7 @@ class PhpSpec extends Plugin
$success = $this->builder->executeCommand($phpspec . ' --format=junit --no-code-generation run');
$output = $this->builder->getLastOutput();
chdir($curdir);
chdir($currentDir);
/*
* process xml output

View file

@ -93,9 +93,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface
return false;
}
$cmd = $this->findBinary('phpunit');
// run without logging
$ret = null;
$cmd = $this->findBinary('phpunit');
$lastLine = exec($cmd.' --log-json . --version');
if (false !== strpos($lastLine, '--log-json')) {
$logFormat = 'junit'; // --log-json is not supported

View file

@ -12,7 +12,7 @@ use SensioLabs\Security\SecurityChecker as BaseSecurityChecker;
/**
* SensioLabs Security Checker Plugin
*
*
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
*/
class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
@ -20,8 +20,8 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
/**
* @var integer
*/
protected $allowed_warnings;
protected $allowedWarnings;
/**
* @return string
*/
@ -37,14 +37,14 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
{
parent::__construct($builder, $build, $options);
$this->allowed_warnings = 0;
$this->allowedWarnings = 0;
if (isset($options['zero_config']) && $options['zero_config']) {
$this->allowed_warnings = -1;
$this->allowedWarnings = -1;
}
if (array_key_exists('allowed_warnings', $options)) {
$this->allowed_warnings = (int)$options['allowed_warnings'];
$this->allowedWarnings = (int)$options['allowed_warnings'];
}
}
@ -76,7 +76,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
if ($warnings) {
foreach ($warnings as $library => $warning) {
foreach ($warning['advisories'] as $advisory => $data) {
foreach ($warning['advisories'] as $data) {
$this->build->reportError(
$this->builder,
'security_checker',
@ -88,7 +88,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
}
}
if ($this->allowed_warnings != -1 && ((int)$checker->getLastVulnerabilityCount() > $this->allowed_warnings)) {
if ($this->allowedWarnings != -1 && ((int)$checker->getLastVulnerabilityCount() > $this->allowedWarnings)) {
$success = false;
}
}

View file

@ -11,7 +11,7 @@ use Maknz\Slack\AttachmentField;
/**
* Slack Plugin
*
*
* @author Stephen Ball <phpci@stephen.rebelinblue.com>
*/
class SlackNotify extends Plugin
@ -21,7 +21,7 @@ class SlackNotify extends Plugin
private $username;
private $message;
private $icon;
private $show_status;
private $showStatus;
/**
* @return string
@ -62,9 +62,9 @@ class SlackNotify extends Plugin
}
if (isset($options['show_status'])) {
$this->show_status = (bool) $options['show_status'];
$this->showStatus = (bool) $options['show_status'];
} else {
$this->show_status = true;
$this->showStatus = true;
}
if (isset($options['icon'])) {
@ -100,7 +100,7 @@ class SlackNotify extends Plugin
}
// Include an attachment which shows the status and hide the message
if ($this->show_status) {
if ($this->showStatus) {
$successfulBuild = $this->build->isSuccessful();
if ($successfulBuild) {

View file

@ -28,7 +28,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
/**
* @var int
*/
protected $allowed_errors;
protected $allowedErrors;
/**
* @var array - paths to ignore
@ -123,7 +123,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
$this->suffixes = ['php'];
$this->directory = $this->builder->buildPath;
$this->ignore = $this->builder->ignore;
$this->allowed_errors = 0;
$this->allowedErrors = 0;
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
if (!empty($options['suffixes']) && is_array($options['suffixes'])) {
@ -135,7 +135,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
}
if (isset($options['zero_config']) && $options['zero_config']) {
$this->allowed_errors = -1;
$this->allowedErrors = -1;
}
$this->setOptions($options);
@ -185,7 +185,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
$this->build->storeMeta('technical_debt-warnings', $errorCount);
if ($this->allowed_errors !== -1 && $errorCount > $this->allowed_errors) {
if ($this->allowedErrors !== -1 && $errorCount > $this->allowedErrors) {
$success = false;
}

View file

@ -8,7 +8,7 @@ use PHPCensor\Plugin;
/**
* XMPP Notification - Send notification for successful or failure build
*
*
* @author Alexandre Russo <dev.github@ange7.com>
*/
class XMPP extends Plugin
@ -48,7 +48,7 @@ class XMPP extends Plugin
/**
* @var string, mask to format date
*/
protected $date_format;
protected $dateFormat;
/**
* @return string
@ -57,7 +57,7 @@ class XMPP extends Plugin
{
return 'xmpp';
}
/**
* {@inheritdoc}
*/
@ -71,7 +71,7 @@ class XMPP extends Plugin
$this->alias = '';
$this->recipients = [];
$this->tls = false;
$this->date_format = '%c';
$this->dateFormat = '%c';
/*
* Set recipients list
@ -189,7 +189,7 @@ class XMPP extends Plugin
$message = "✘ [".$this->build->getProjectTitle()."] Build #" . $this->build->getId()." failure";
}
$message .= ' ('.strftime($this->date_format).')';
$message .= ' ('.strftime($this->dateFormat).')';
return file_put_contents($message_file, $message);
}