Skip to content

Commit 02add34

Browse files
committed
Test JS files as well
1 parent 02dbfa0 commit 02add34

File tree

10 files changed

+43
-30
lines changed

10 files changed

+43
-30
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- if [ -s php-l-results ]; then cat php-l-results; exit 1; fi
1818
- COMPOSER_BIN=$(composer global config --absolute bin-dir)
1919
- $COMPOSER_BIN/phpunit --bootstrap ./tests/bootstrap.php --verbose ./tests
20-
- $COMPOSER_BIN/phpcs . --standard=phpcs.xml --extensions=php,phtml,css -p
20+
- $COMPOSER_BIN/phpcs . -p -s
2121
- name: "PHP 7.4 Syntax, linter and tests"
2222
php: "7.4"
2323
install:
@@ -29,7 +29,7 @@ jobs:
2929
- if [ -s php-l-results ]; then cat php-l-results; exit 1; fi
3030
- COMPOSER_BIN=$(composer global config --absolute bin-dir)
3131
- $COMPOSER_BIN/phpunit --bootstrap ./tests/bootstrap.php --verbose ./tests
32-
- $COMPOSER_BIN/phpcs . --standard=phpcs.xml --extensions=php,phtml,css -p
32+
- $COMPOSER_BIN/phpcs . -p -s
3333
- name: "PHP 5.6 Syntax"
3434
php: "5.6"
3535
script:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ test: bin/phpunit ## Run the test suite
6161

6262
.PHONY: lint
6363
lint: bin/phpcs ## Run the linter on the PHP files
64-
$(PHP) ./bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
64+
$(PHP) ./bin/phpcs . -p -s
6565

6666
.PHONY: lint-fix
6767
lint-fix: bin/phpcbf ## Fix the errors detected by the linter
68-
$(PHP) ./bin/phpcbf . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
68+
$(PHP) ./bin/phpcbf . -p -s
6969

7070
bin/phpunit:
7171
mkdir -p bin/

app/Controllers/feedController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush
365365
} else { //This entry already exists but has been updated
366366
//Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->url(false) .
367367
//', old hash ' . $existingHash . ', new hash ' . $entry->hash());
368-
$mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? (
369-
$feed->attributes('mark_updated_article_unread')
370-
) : FreshRSS_Context::$user_conf->mark_updated_article_unread;
368+
$mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ?
369+
$feed->attributes('mark_updated_article_unread') :
370+
FreshRSS_Context::$user_conf->mark_updated_article_unread;
371371
$needFeedCacheRefresh = $mark_updated_article_unread;
372372
$entry->_isRead($mark_updated_article_unread ? false : null); //Change is_read according to policy.
373373

app/views/helpers/feed/update.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@
308308
<div class="group-controls">
309309
<div class="stick">
310310
<input type="text" name="curl_params_cookie" id="curl_params_cookie" class="extend" value="<?=
311-
is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_COOKIE]) ? (
312-
$this->feed->attributes('curl_params')[CURLOPT_COOKIE]) : ''
311+
is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_COOKIE]) ?
312+
$this->feed->attributes('curl_params')[CURLOPT_COOKIE] : ''
313313
?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
314314
</div>
315315
<p class="help"><?= _i('help') ?> <?= _t('sub.feed.css_cookie_help') ?></p>
@@ -342,8 +342,8 @@
342342
</select>
343343
<div class="stick">
344344
<input type="text" name="curl_params" id="curl_params" class="extend" value="<?=
345-
is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_PROXY]) ? (
346-
$this->feed->attributes('curl_params')[CURLOPT_PROXY]) : ''
345+
is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_PROXY]) ?
346+
$this->feed->attributes('curl_params')[CURLOPT_PROXY] : ''
347347
?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
348348
</div>
349349
<p class="help"><?= _i('help') ?> <?= _t('sub.feed.proxy_help') ?></p>

app/views/user/manage.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<select name="new_user_language" id="new_user_language">
1414
<?php $languages = Minz_Translate::availableLanguages(); ?>
1515
<?php foreach ($languages as $lang) { ?>
16-
<option value="<?= $lang ?>"<?= FreshRSS_Context::$user_conf->language === $lang ? (
17-
' selected="selected"') : '' ?>><?= _t('gen.lang.' . $lang) ?></option>
16+
<option value="<?= $lang ?>"<?= FreshRSS_Context::$user_conf->language === $lang ?
17+
' selected="selected"' : '' ?>><?= _t('gen.lang.' . $lang) ?></option>
1818
<?php } ?>
1919
</select>
2020
</div>

p/scripts/install.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function hide_password(ev) {
1717
return false;
1818
}
1919
const toggles = document.getElementsByClassName('toggle-password');
20-
for (let i = 0 ; i < toggles.length ; i++) {
20+
for (let i = 0; i < toggles.length; i++) {
2121
toggles[i].addEventListener('mousedown', show_password);
2222
toggles[i].addEventListener('mouseup', hide_password);
2323
}
@@ -68,7 +68,7 @@ function ask_confirmation(ev) {
6868
}
6969
}
7070
const confirms = document.getElementsByClassName('confirm');
71-
for (let i = 0 ; i < confirms.length ; i++) {
71+
for (let i = 0; i < confirms.length; i++) {
7272
confirms[i].addEventListener('click', ask_confirmation);
7373
}
7474
// @license-end

p/scripts/integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const init_integration = function() {
1515
document.querySelector('.share.add').addEventListener('click', event => {
1616
const shareTypes = event.target.closest('.group-controls').querySelector('select');
1717
const shareType = shareTypes.options[shareTypes.selectedIndex];
18-
let newShare = event.target.closest('form').getAttribute(`data-${shareType.getAttribute('data-form')}`);
18+
let newShare = event.target.closest('form').getAttribute('data-' + shareType.getAttribute('data-form'));
1919
newShare = newShare.replace(/##label##/g, shareType.text);
2020
newShare = newShare.replace(/##type##/g, shareType.value);
2121
newShare = newShare.replace(/##help##/g, shareType.getAttribute('data-help'));

p/scripts/main.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ if (!Element.prototype.remove) Element.prototype.remove = function () { if (this
2121
function xmlHttpRequestJson(req) {
2222
let json = req.response;
2323
if (req.responseType !== 'json') { //IE11
24-
try { json = JSON.parse(req.responseText); }
25-
catch (ex) { json = null; }
24+
try {
25+
json = JSON.parse(req.responseText);
26+
} catch (ex) {
27+
json = null;
28+
}
2629
}
2730
return json;
2831
}
@@ -81,7 +84,7 @@ function numberFormat(nStr) {
8184
rgx = /(\d+)(\d{3})/;
8285
let x1 = x[0];
8386
while (rgx.test(x1)) {
84-
x1 = x1.replace(rgx, '$1' + ' ' + '$2');
87+
x1 = x1.replace(rgx, '$1 $2');
8588
}
8689
return x1 + x2;
8790
}
@@ -908,7 +911,7 @@ function init_shortcuts() {
908911
if (k === s.reading_view) { delayedClick(document.querySelector('#nav_menu_views .view-reader')); return false; }
909912
if (k === s.global_view) { delayedClick(document.querySelector('#nav_menu_views .view-global')); return false; }
910913
if (k === s.rss_view) { delayedClick(document.querySelector('#nav_menu_views .view-rss')); return false; }
911-
if (k === s.toggle_media) { toggle_media(); return false;}
914+
if (k === s.toggle_media) { toggle_media(); return false; }
912915
return true;
913916
};
914917
}

p/scripts/stats.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function initStats() {
3232
grid: {verticalLines: false},
3333
xaxis: {noTicks: 6, showLabels: false, tickDecimals: 0, min: -30.75, max: -0.25},
3434
yaxis: {min: 0},
35-
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
35+
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function (obj) { return numberFormat(obj.y); }},
3636
});
3737
// Feed per category
3838
Flotr.draw(document.getElementById('statsFeedPerCategory'),
@@ -42,18 +42,22 @@ function initStats() {
4242
pie: {explode: 10, show: true, labelFormatter: function(){return '';}},
4343
xaxis: {showLabels: false},
4444
yaxis: {showLabels: false},
45-
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ numberFormat(obj.y) + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
45+
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function (obj) {
46+
return obj.series.label + ' - ' + numberFormat(obj.y) + ' (' + (obj.fraction * 100).toFixed(1) + '%)';
47+
}},
4648
legend: {container: document.getElementById('statsFeedPerCategoryLegend'), noColumns: 3}
4749
});
4850
// Entry per category
4951
Flotr.draw(document.getElementById('statsEntryPerCategory'),
5052
stats.entryByCategory,
5153
{
5254
grid: {verticalLines: false, horizontalLines: false},
53-
pie: {explode: 10, show: true, labelFormatter: function(){return '';}},
55+
pie: {explode: 10, show: true, labelFormatter: function () { return ''; }},
5456
xaxis: {showLabels: false},
5557
yaxis: {showLabels: false},
56-
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ numberFormat(obj.y) + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
58+
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function (obj) {
59+
return obj.series.label + ' - ' + numberFormat(obj.y) + ' (' + (obj.fraction * 100).toFixed(1) + '%)';
60+
}},
5761
legend: {container: document.getElementById('statsEntryPerCategoryLegend'), noColumns: 3}
5862
});
5963
}

phpcs.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ruleset name="FreshRSS Ruleset">
33
<description>Created with the PHP Coding Standard Generator. https://edorian.github.com/php-coding-standard-generator/</description>
4+
<arg name="extensions" value="php,phtml,css,js"/>
45
<arg name="tab-width" value="4"/>
56
<exclude-pattern>./lib/SimplePie/</exclude-pattern>
67
<exclude-pattern>./lib/PHPMailer/</exclude-pattern>
@@ -10,6 +11,7 @@
1011
<exclude-pattern>./data/config.php</exclude-pattern>
1112
<exclude-pattern>./data/users/*/config.php</exclude-pattern>
1213
<exclude-pattern>./extensions/</exclude-pattern>
14+
<exclude-pattern>*.min.js$</exclude-pattern>
1315
<!-- Duplicate class names are not allowed -->
1416
<rule ref="Generic.Classes.DuplicateClassName"/>
1517
<!-- Statements must not be empty -->
@@ -25,7 +27,7 @@
2527
<!-- For language strings maximum line lengths make little sense. -->
2628
<exclude-pattern>./app/i18n/</exclude-pattern>
2729
<!-- Don't enforce line length on the HTML; the point is to improve legibility, not reduce it -->
28-
<exclude-pattern>*.phtml</exclude-pattern>
30+
<exclude-pattern>*.phtml$</exclude-pattern>
2931
<properties>
3032
<property name="lineLimit" value="165"/>
3133
<property name="absoluteLineLimit" value="190"/>
@@ -88,22 +90,26 @@
8890
<!-- Do not add spaces when casting -->
8991
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
9092
<!-- Operators must have a space around them -->
91-
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
93+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
94+
<properties>
95+
<property name="ignoreNewlines" value="true" />
96+
</properties>
97+
</rule>
9298
<!-- Do not add a whitespace before a semicolon -->
9399
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
94100
<!-- Do not add whitespace at start or end of a file or end of a line -->
95101
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
96102
<!-- Expected space after closing parenthesis -->
97103
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis">
98-
<exclude-pattern>.phtml</exclude-pattern>
104+
<exclude-pattern>.phtml$</exclude-pattern>
99105
</rule>
100106
<!-- Newline required after opening brace -->
101107
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
102-
<exclude-pattern>.phtml</exclude-pattern>
108+
<exclude-pattern>.phtml$</exclude-pattern>
109+
<exclude-pattern>.js$</exclude-pattern>
103110
</rule>
104111
<!-- No PHP code was found in this file -->
105112
<rule ref="Internal.NoCodeFound">
106-
<exclude-pattern>.css</exclude-pattern>
107-
<exclude-pattern>.phtml</exclude-pattern>
113+
<exclude-pattern>.phtml$</exclude-pattern>
108114
</rule>
109115
</ruleset>

0 commit comments

Comments
 (0)