1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-10 18:44:04 +02:00

[phpcs] Add missing rules

- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
This commit is contained in:
logmanoriginal
2017-07-29 19:28:00 +02:00
parent 38b56bf23a
commit a4b9611e66
128 changed files with 692 additions and 694 deletions

View File

@@ -32,19 +32,19 @@ define('CACHE_DIR', __DIR__ . '/cache');
Debugging allows displaying PHP error messages and bypasses the cache: this can allow a malicious
client to retrieve data about your server and hammer a provider throught your rss-bridge instance.
*/
if(file_exists('DEBUG')){
if(file_exists('DEBUG')) {
$debug_enabled = true;
$debug_whitelist = trim(file_get_contents('DEBUG'));
if(strlen($debug_whitelist) > 0){
if(strlen($debug_whitelist) > 0) {
$debug_enabled = false;
foreach(explode("\n", $debug_whitelist) as $allowed_ip){
if(trim($allowed_ip) === $_SERVER['REMOTE_ADDR']){
foreach(explode("\n", $debug_whitelist) as $allowed_ip) {
if(trim($allowed_ip) === $_SERVER['REMOTE_ADDR']) {
$debug_enabled = true;
break;
}
}
}
if($debug_enabled){
if($debug_enabled) {
ini_set('display_errors', '1');
error_reporting(E_ALL);
define('DEBUG', true);
@@ -102,7 +102,7 @@ try {
Format::setDir(__DIR__ . '/formats/');
Cache::setDir(__DIR__ . '/caches/');
if(!file_exists($whitelist_file)){
if(!file_exists($whitelist_file)) {
$whitelist_selection = $whitelist_default;
$whitelist_write = implode("\n", $whitelist_default);
file_put_contents($whitelist_file, $whitelist_write);
@@ -119,10 +119,10 @@ try {
$action = filter_input(INPUT_GET, 'action');
$bridge = filter_input(INPUT_GET, 'bridge');
if($action === 'display' && !empty($bridge)){
if($action === 'display' && !empty($bridge)) {
// DEPRECATED: 'nameBridge' scheme is replaced by 'name' in bridge parameter values
// this is to keep compatibility until futher complete removal
if(($pos = strpos($bridge, 'Bridge')) === (strlen($bridge) - strlen('Bridge'))){
if(($pos = strpos($bridge, 'Bridge')) === (strlen($bridge) - strlen('Bridge'))) {
$bridge = substr($bridge, 0, $pos);
}
@@ -130,12 +130,12 @@ try {
// DEPRECATED: 'nameFormat' scheme is replaced by 'name' in format parameter values
// this is to keep compatibility until futher complete removal
if(($pos = strpos($format, 'Format')) === (strlen($format) - strlen('Format'))){
if(($pos = strpos($format, 'Format')) === (strlen($format) - strlen('Format'))) {
$format = substr($format, 0, $pos);
}
// whitelist control
if(!Bridge::isWhitelisted($whitelist_selection, $bridge)){
if(!Bridge::isWhitelisted($whitelist_selection, $bridge)) {
throw new \HttpException('This bridge is not whitelisted', 401);
die;
}
@@ -144,7 +144,7 @@ try {
$bridge = Bridge::create($bridge);
$noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN);
if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy){
if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy) {
define('NOPROXY', true);
}
@@ -165,7 +165,7 @@ try {
try {
$bridge->setCache($cache);
$bridge->setDatas($params);
} catch(Exception $e){
} catch(Exception $e) {
header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode()));
header('Content-Type: text/html');
die(buildBridgeException($e, $bridge));
@@ -177,7 +177,7 @@ try {
$format->setItems($bridge->getItems());
$format->setExtraInfos($bridge->getExtraInfos());
$format->display();
} catch(Exception $e){
} catch(Exception $e) {
header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode()));
header('Content-Type: text/html');
die(buildTransformException($e, $bridge));
@@ -185,15 +185,11 @@ try {
die;
}
}
catch(HttpException $e){
} catch(HttpException $e) {
header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode()));
header('Content-Type: text/plain');
die($e->getMessage());
}
catch(\Exception $e){
} catch(\Exception $e) {
die($e->getMessage());
}
@@ -221,7 +217,7 @@ $formats = Format::searchInformation();
<body onload="search()">
<?php
$status = '';
if(defined('DEBUG') && DEBUG === true){
if(defined('DEBUG') && DEBUG === true) {
$status .= 'debug mode active';
}
@@ -244,8 +240,8 @@ EOD;
$showInactive = filter_input(INPUT_GET, 'show_inactive', FILTER_VALIDATE_BOOLEAN);
$inactiveBridges = '';
$bridgeList = Bridge::listBridges();
foreach($bridgeList as $bridgeName){
if(Bridge::isWhitelisted($whitelist_selection, $bridgeName)){
foreach($bridgeList as $bridgeName) {
if(Bridge::isWhitelisted($whitelist_selection, $bridgeName)) {
echo displayBridgeCard($bridgeName, $formats);
$activeFoundBridgeCount++;
} elseif($showInactive) {
@@ -259,7 +255,7 @@ EOD;
<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge alpha 0.2 ~ Public Domain</a><br />
<?= $activeFoundBridgeCount; ?>/<?= count($bridgeList) ?> active bridges. <br />
<?php
if($activeFoundBridgeCount !== count($bridgeList)){
if($activeFoundBridgeCount !== count($bridgeList)) {
// FIXME: This should be done in pure CSS
if(!$showInactive)
echo '<a href="?show_inactive=1"><button class="small">Show inactive bridges</button></a><br />';