Merge pull request #282 from Icinga/psr12

PSR12
This commit is contained in:
Johannes Meyer 2022-09-22 09:01:30 +02:00 committed by GitHub
commit dae46c61d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 54 additions and 53 deletions

View file

@ -39,4 +39,4 @@ jobs:
- name: PHP CodeSniffer
if: success() || matrix.allow_failure
run: phpcs
run: phpcs -wps --colors

View file

@ -1,25 +0,0 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>Sniff our code a while</description>
<file>./</file>
<exclude-pattern>vendor/*</exclude-pattern>
<arg value="wps"/>
<arg name="report-width" value="auto"/>
<arg name="report-full"/>
<arg name="report-gitblame"/>
<arg name="report-summary"/>
<arg name="encoding" value="UTF-8"/>
<arg name="extensions" value="php"/>
<rule ref="PSR2"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
</ruleset>

View file

@ -1,4 +1,5 @@
<?php
/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Graphite\Clicommands;
@ -124,11 +125,13 @@ EOT
$macros['service_name_template'] = [''];
foreach ($this->cartesianProduct($macros) as $macroValues) {
if (preg_match(
'/\A\.[^.]+\.(.+)\.[^.]+\z/',
$metricFilter->resolve($macroValues),
$match
)) {
if (
preg_match(
'/\A\.[^.]+\.(.+)\.[^.]+\z/',
$metricFilter->resolve($macroValues),
$match
)
) {
$perfdata[$match[1]] = $max;
}
}

View file

@ -145,10 +145,13 @@ class CommonForm extends Form
$params = $this->getRedirectUrl()->getParams();
$seconds = TimeRangePickerTools::getRelativeSeconds($params);
if ($seconds === null && count(array_intersect_key(
$params->toArray(false),
array_keys(TimeRangePickerTools::getAllRangeParameters())
)) === 0) {
if (
$seconds === null
&& count(array_intersect_key(
$params->toArray(false),
array_keys(TimeRangePickerTools::getAllRangeParameters())
)) === 0
) {
$seconds = TimeRangePickerTools::getDefaultRelativeTimeRange();
}

View file

@ -134,7 +134,8 @@ class Template
if (! isset($handledCurves[$curveName2])) {
foreach ($metrics1 as $metric1 => & $vars1) {
foreach ($metrics2 as $metric2 => & $vars2) {
if (count(array_intersect_assoc($vars1, $vars2))
if (
count(array_intersect_assoc($vars1, $vars2))
=== count(array_intersect_key($vars1, $vars2))
) {
$possibleCombinations[$curveName1][$curveName2][$metric1][$metric2] = true;

View file

@ -71,14 +71,16 @@ class Templates
*/
public function loadDir($path)
{
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
$path,
RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO
foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
$path,
RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO
| RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::FOLLOW_SYMLINKS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $filepath => $fileinfo) {
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $filepath => $fileinfo
) {
/** @var SplFileInfo $fileinfo */
if ($fileinfo->isFile() && preg_match('/\A[^.].*\.ini\z/si', $fileinfo->getFilename())) {
@ -171,10 +173,12 @@ class Templates
);
}
if (count(array_intersect(
$curves[$curve][0]->getMacros(),
['host_name_template', 'service_name_template']
)) !== 1) {
if (
count(array_intersect(
$curves[$curve][0]->getMacros(),
['host_name_template', 'service_name_template']
)) !== 1
) {
throw new ConfigurationError(
'Bad metrics filter "%s" for curve "%s" of template "%s" in file "%s": must include'
. ' either the macro $host_name_template$ or $service_name_template$, but not both',

View file

@ -6,5 +6,4 @@ use Icinga\Module\Icingadb\Hook\IcingadbSupportHook;
class IcingadbSupport extends IcingadbSupportHook
{
}

View file

@ -3,7 +3,6 @@
namespace Icinga\Module\Graphite\ProvidedHook\Icingadb;
use Icinga\Application\Icinga;
use Icinga\Module\Graphite\Util\InternalProcessTracker as IPT;
use Icinga\Module\Graphite\Web\Controller\TimeRangePickerTrait;
use Icinga\Module\Graphite\Web\Widget\Graphs;

View file

@ -246,10 +246,12 @@ abstract class Graphs extends AbstractWidget
IPT::recordf("Icinga check command: %s", $this->checkCommand);
IPT::recordf("Obscured check command: %s", $this->obscuredCheckCommand);
foreach ([
foreach (
[
['template', $concreteTemplates, []],
['default_template', $allTemplates->getDefaultTemplates(), $excludedMetrics],
] as $templateSet) {
] as $templateSet
) {
list($urlParam, $templates, $excludeMetrics) = $templateSet;
if ($urlParam === 'template') {

View file

@ -5,7 +5,7 @@ namespace Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb;
use Icinga\Module\Graphite\Graphing\Template;
use Icinga\Module\Graphite\Web\Widget\Graphs;
use Icinga\Web\Url;
use \Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\Host;
class IcingadbHost extends Graphs
{

View file

@ -5,7 +5,7 @@ namespace Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb;
use Icinga\Module\Graphite\Graphing\Template;
use Icinga\Module\Graphite\Web\Widget\Graphs;
use Icinga\Web\Url;
use \Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Model\Service;
class IcingadbService extends Graphs
{

15
phpcs.xml Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ruleset name="PSR12">
<!-- Test all PHP files except those in vendor/ -->
<file>./</file>
<arg name="extensions" value="php"/>
<exclude-pattern>vendor/*</exclude-pattern>
<arg name="report-width" value="auto"/>
<arg name="report-full"/>
<arg name="report-gitblame"/>
<arg name="report-summary"/>
<arg name="encoding" value="UTF-8"/>
<rule ref="PSR12"/>
</ruleset>