Skip to content

Commit

Permalink
Update and fix composer.json, clear sniffs warnings and errors (#836)
Browse files Browse the repository at this point in the history
* update require-dev dependencies inside composer.json

* update scripts part inside composer.jos, make phpcs, fix and lint working

* chore (build): add composer fix command to makefile

* remove exclude-pattern tab from phpcs configuration

* fix sniff MediaWiki.WhiteSpace.SpaceyParenthesis reported by phpcs

* fix sniff MediaWiki.WhiteSpace.MultipleEmptyLines reported by phpcs

* fix sniff Squiz.WhiteSpace.FunctionOpeningBraceSpace reported by phpcs

* fix (composer): exclude extensions from phpcs and lint

* fix sniff MediaWiki.Commenting.FunctionComment reported by phpcs

* fix sniff Universal.WhiteSpace.CommaSpacing reported by phpcs

* fix sniff Squiz.WhiteSpace.SuperfluousWhitespace reported by phpcs

* fix sniff PSR2.ControlStructures.SwitchDeclaration reported by phpcs

* fix sniff MediaWiki.PHPUnit.MockBoilerplate reported by phpcs

* fix sniff Generic.Files.LineEndings reported by phpcs

* fix sniff PSR2.Files.EndFileNewline reported by phpcs

* fix sniff Squiz.ControlStructures.ControlSignature reported by phpcs

* fix sniff Squiz.Classes.SelfMemberReference reported by phpcs

* fix sniff MediaWiki.Commenting.PhpunitAnnotations reported by phpcs

* fix sniff Generic.WhiteSpace.DisallowSpaceIndent reported by phpcs

* fix sniff MediaWiki.Commenting.RedundantVarName reported by phpcs

* fix sniff MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment reported by phpcs

* fix sniff Generic.Functions.OpeningFunctionBraceKernighanRitchie reported by phpcs

* fix sniff MediaWiki.Commenting.DocComment reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionComment.SpacingAfter reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionComment.WrongStyle reported by phpcs

* fix sniff Squiz.Scope.MethodScope.Missing reported by phpcs

* fix sniff Generic.ControlStructures.InlineControlStructure.NotAllowed reported by phpcs

* fix sniff Generic.CodeAnalysis.AssignmentInCondition.Found reported by phpcs

* fix sniff MediaWiki.Commenting.PropertyDocumentation.MissingVarType reported by phpcs

* reverse the changes for Generic.CodeAnalysis.AssignmentInCondition.Found, exclude them

* fix sniff Generic.WhiteSpace.ScopeIndent.Incorrect reported by phpcs

* fix sniff Universal.Lists.DisallowLongListSyntax reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionAnnotations.UnrecognizedAnnotation reported by phpcs

* fix sniff Generic.PHP.LowerCaseKeyword.Found reported by phpcs

* fix sniff MediaWiki.Commenting.MissingCovers.MissingCovers reported by phpcs

* fix sniff MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment reported by phpcs

* fix sniff MediaWiki.Commenting.PhpunitAnnotations.NotClass reported by phpcs

* fix sniff MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage reported by phpcs

* fix sniff Squiz.Operators.ValidLogicalOperators.NotAllowed reported by phpcs

* reverse previous commit

* fix sniff MediaWiki.Commenting.FunctionComment.ParamNameNoCaseMatch reported by phpcs

* fix sniff Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace reported by phpcs

* fix sniff Generic.WhiteSpace.ScopeIndent.IncorrectExact reported by phpcs

* fix sniff PSR2.Classes.PropertyDeclaration.Multiple reported by phpcs

* fix sniff MediaWiki.Commenting.DocComment.SyntaxAlignedDocClose reported by phpcs

* fix sniff PSR2.ControlStructures.ElseIfDeclaration.NotAllowed reported by phpcs

* fix sniff Generic.Arrays.DisallowLongArraySyntax.Found reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionComment.ExtraParamComment reported by phpcs

* fix sniff Squiz.PHP.NonExecutableCode.Unreachable reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionComment.MissingReturnType reported by phpcs

* fix sniff PSR2.ControlStructures.SwitchDeclaration.TerminatingComment reported by phpcs

* fix sniff MediaWiki.Commenting.PropertyDocumentation.TypeTypeHintVar reported by phpcs

* fix sniff PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase reported by phpcs

* fix sniff MediaWiki.Commenting.LicenseComment.LicenceTag reported by phpcs

* fix sniff PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter reported by phpcs

* fix sniff MediaWiki.Usage.StaticClosure.StaticClosure reported by phpcs

* fix sniff MediaWiki.VariableAnalysis.UnusedGlobalVariables.UnusedGlobal$smwgQMaxLimit reported by phpcs

* fix sniff Squiz.WhiteSpace.OperatorSpacing.SpacingAfter reported by phpcs

* fix sniff MediaWiki.WhiteSpace.SpaceAfterClosure.NoWhitespaceAfterClosure reported by phpcs

* fix sniff Squiz.WhiteSpace.SemicolonSpacing.Incorrect reported by phpcs

* fix sniff Squiz.WhiteSpace.OperatorSpacing.SpacingBefore reported by phpcs

* fix sniff MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle reported by phpcs

* fix sniff Universal.UseStatements.NoUselessAliases.Found reported by phpcs

* fix sniff MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace reported by phpcs

* fix sniff MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix reported by phpcs

* fix sniff MediaWiki.Commenting.FunctionComment.MissingParamName reported by phpcs

* fix sniff MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgContLang reported by phpcs

* fix sniff MediaWiki.Classes.UnusedUseStatement.UnusedUse reported by phpcs

* fix sniff MediaWiki.Classes.UnsortedUseStatements.UnsortedUse reported by phpc

* fix sniff PSR12.Properties.ConstantVisibility.NotFound reported by phpcs

* add exclude and rule tags to phpcs.xml
  • Loading branch information
gesinn-it-ilm authored Jun 10, 2024
1 parent 23f535b commit 5515deb
Show file tree
Hide file tree
Showing 86 changed files with 1,205 additions and 1,097 deletions.
24 changes: 21 additions & 3 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,34 @@
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
<exclude name="PSR12.Properties.ConstantVisibility.NotFound" />
<exclude name="MediaWiki.Commenting.FunctionComment.NoParamType" />
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
<exclude name="MediaWiki.PHPUnit.AssertEmpty.AssertEmptyUsed" />
<exclude name="Squiz.Operators.ValidLogicalOperators.NotAllowed" />
<exclude name="Generic.ControlStructures.DisallowYodaConditions.Found" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound" />
</rule>
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
<properties>
<property name="allowedPrefixes" type="array" value="eg,wg" />
</properties>
</rule>
<rule ref="MediaWiki.Commenting.FunctionComment.ObjectTypeHintReturn">
<severity>0</severity>
</rule>
<file>.</file>
<exclude-pattern>/(vendor|conf|extensions)/</exclude-pattern>
<exclude-pattern>/(vendor|conf)/</exclude-pattern>
<exclude-pattern type="relative">extensions/*</exclude-pattern>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
</ruleset>
5 changes: 3 additions & 2 deletions DefaultSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@

// Load hash format only if HashTables extension is initialised, otherwise 'Array' format is enough
// FIXME: According to the INSTALL file only formats should be enabled, that "do not require further software to be installed (besides SMW)"
// Version < 1.0 alpha
if ( isset( $GLOBALS['wgAutoloadClasses']['ExtHashTables'] ) && defined( 'ExtHashTables::VERSION' )
&& version_compare( ExtHashTables::VERSION, '0.999', '>=' )
|| isset( $GLOBALS['wgHashTables'] ) // Version < 1.0 alpha
|| isset( $GLOBALS['wgHashTables'] )
) {
$GLOBALS['srfgFormats'][] = 'hash';
}
Expand Down Expand Up @@ -136,7 +137,7 @@
'cc210',
'cc252',
'cc267',
'cc294' ,
'cc294',
'cc303',
'cc327',
'ylgn',
Expand Down
4 changes: 2 additions & 2 deletions Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

$moduleTemplate = [
'localBasePath' => __DIR__ ,
'localBasePath' => __DIR__,
'remoteExtPath' => 'SemanticResultFormats'
];

Expand Down Expand Up @@ -1017,7 +1017,7 @@

'ext.srf.datatables.v2.module' => $moduleTemplate + [
'scripts' => [
'resources/jquery/datatables/object_hash.js',
'resources/jquery/datatables/object_hash.js',
'resources/jquery/datatables/jquery.mark.min.js',
'resources/jquery/datatables/datatables.mark.min.js',
'resources/jquery/datatables/datatables.min.js',
Expand Down
30 changes: 18 additions & 12 deletions SemanticResultFormats.parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@
*/
class SRFParserFunctions {

static function registerFunctions( &$parser ) {
public static function registerFunctions( &$parser ) {
$parser->setFunctionHook( 'calendarstartdate', [ 'SRFParserFunctions', 'runCalendarStartDate' ] );
$parser->setFunctionHook( 'calendarenddate', [ 'SRFParserFunctions', 'runCalendarEndDate' ] );
return true;
}

static function runCalendarStartDate( &$parser, $calendar_type = 'month', $calendar_start_day = null, $calendar_days = 7, $default_year = null, $default_month = null, $default_day = null ) {
if ( $calendar_type == '' ) { $calendar_type = 'month';
public static function runCalendarStartDate( &$parser, $calendar_type = 'month', $calendar_start_day = null, $calendar_days = 7, $default_year = null, $default_month = null, $default_day = null ) {
if ( $calendar_type == '' ) {
$calendar_type = 'month';
}
list( $lower_date, $upper_date, $query_date ) =
[ $lower_date, $upper_date, $query_date ] =
self::getBoundaryDates( $calendar_type, $calendar_start_day, $calendar_days, $default_year, $default_month, $default_day );
return date( "Y", $lower_date ) . '-' . date( "m", $lower_date ) . '-' . date( "d", $lower_date );
}

static function runCalendarEndDate( &$parser, $calendar_type = 'month', $calendar_start_day = null, $calendar_days = 7, $default_year = null, $default_month = null, $default_day = null ) {
if ( $calendar_type == '' ) { $calendar_type = 'month';
public static function runCalendarEndDate( &$parser, $calendar_type = 'month', $calendar_start_day = null, $calendar_days = 7, $default_year = null, $default_month = null, $default_day = null ) {
if ( $calendar_type == '' ) {
$calendar_type = 'month';
}
list( $lower_date, $upper_date, $query_date ) =
[ $lower_date, $upper_date, $query_date ] =
self::getBoundaryDates( $calendar_type, $calendar_start_day, $calendar_days, $default_year, $default_month, $default_day );
return date( "Y", $upper_date ) . '-' . date( "m", $upper_date ) . '-' . date( "d", $upper_date );
}
Expand Down Expand Up @@ -60,15 +62,19 @@ static function runCalendarEndDate( &$parser, $calendar_type = 'month', $calenda
* the year/month/day to be queried.
*
*/
static function getBoundaryDates( $calendar_type = 'month', $calendar_start_day = null, $calendar_days = 7, $default_year = null, $default_month = null, $default_day = null ) {
if ( $calendar_type == 'month' ) { $calendar_start_day = 0;
public static function getBoundaryDates( $calendar_type = 'month', $calendar_start_day = null, $calendar_days = 7, $default_year = null, $default_month = null, $default_day = null ) {
if ( $calendar_type == 'month' ) {
$calendar_start_day = 0;
}

if ( $default_year == null ) { $default_year = date( "Y", time() );
if ( $default_year == null ) {
$default_year = date( "Y", time() );
}
if ( $default_month == null ) { $default_month = date( "n", time() );
if ( $default_month == null ) {
$default_month = date( "n", time() );
}
if ( $default_day == null ) { $default_day = date( "j", time() );
if ( $default_day == null ) {
$default_day = date( "j", time() );
}

global $wgRequest;
Expand Down
4 changes: 2 additions & 2 deletions SemanticResultFormats.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function initExtension( $credits = [] ) {
$GLOBALS['wgExtensionMessagesFiles']['SemanticResultFormats'] = __DIR__ . '/SemanticResultFormats.i18n.php';
$GLOBALS['wgExtensionMessagesFiles']['SemanticResultFormatsMagic'] = __DIR__ . '/SemanticResultFormats.i18n.magic.php';

$GLOBALS['srfgIP'] = __DIR__;
$GLOBALS['wgSrfgIP'] = __DIR__;
$GLOBALS['wgResourceModules'] = array_merge( $GLOBALS['wgResourceModules'], include __DIR__ . "/Resources.php" );
}

Expand Down Expand Up @@ -161,7 +161,7 @@ public static function onExtensionFunction() {
'incoming' => 'SRFIncoming',
'media' => 'SRF\MediaPlayer',
'datatables' => 'SRF\DataTables',
'carousel' => 'SRF\Carousel',
'carousel' => 'SRF\Carousel',
'gantt' => 'SRF\Gantt\GanttPrinter',
'prolog' => 'SRF\Prolog\PrologPrinter',
'dataframe' => 'SRF\dataframe\DataframePrinter',
Expand Down
2 changes: 1 addition & 1 deletion SemanticResultFormats.utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function addGlobalJSVariables() {
}

/**
* @brief Returns semantic search link for the current query
* Returns semantic search link for the current query
*
* Generate a link to access the current ask query
*
Expand Down
2 changes: 1 addition & 1 deletion build
33 changes: 18 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,33 @@
},
"scripts":{
"test": [
"@analyze",
"@phpunit"
],
"test-coverage": [
"@analyze",
"@phpunit-coverage"
],
"phpunit": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist",
"phpunit-coverage": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml",
"integration": "composer phpunit -- --testsuite=semantic-result-formats-integration",
"lint": [
"@parallel-lint",
"minus-x check .",
"@phpcs"
"analyze": [
"@lint",
"@phpcs",
"@minus-x"
],
"fix": [
"minus-x fix .",
"phpcbf"
"@phpcs-fix"
],
"phpcs": "phpcs -sp",
"parallel-lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude conf"
"phpunit": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist",
"phpunit-coverage": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml",
"integration": "composer phpunit -- --testsuite=semantic-result-formats-integration",
"phpcs": "phpcs -ps -d memory_limit=2G",
"phpcs-fix": "phpcbf -p",
"lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude extensions",
"minus-x": "minus-x check ."
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "38.0.0",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "0.5.0",
"php-parallel-lint/php-parallel-lint": "1.3.1"
"mediawiki/mediawiki-codesniffer": "43.0.0",
"mediawiki/minus-x": "1.1.3",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.4.0"
}
}
Loading

0 comments on commit 5515deb

Please sign in to comment.