Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/372916 )
Change subject: Require only one class/interface/trait per file ...................................................................... Require only one class/interface/trait per file This is in preparation of PSR-4 compliance. In a few places our test suite uses multiple classes in the same file, so just list those errors in the .expect file since it's not worth fixing them. Bug: T173798 Change-Id: I385b8758cc15171ed925df417304669bb6b0f9e6 --- M MediaWiki/Tests/files/Commenting/commenting_function.php.expect M MediaWiki/Tests/files/Usage/extend_class_usage.php.expect M MediaWiki/Tests/files/WhiteSpace/space_before_class_brace.php.expect M MediaWiki/ruleset.xml 4 files changed, 60 insertions(+), 32 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer refs/changes/16/372916/1 diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.expect b/MediaWiki/Tests/files/Commenting/commenting_function.php.expect index 46f702c..43aa70d 100644 --- a/MediaWiki/Tests/files/Commenting/commenting_function.php.expect +++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.expect @@ -1,32 +1,37 @@ - 5 | ERROR | [ ] Missing function doc comment - | | (MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic) - 9 | ERROR | [ ] Missing function doc comment - | | (MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic) - 16 | ERROR | [ ] Missing @return tag in function comment - | | (MediaWiki.Commenting.FunctionComment.MissingReturn) - 22 | ERROR | [x] Expected 1 spaces after parameter name; 2 found - | | (MediaWiki.Commenting.FunctionComment.SpacingAfterParamName) - 23 | ERROR | [x] Expected 1 spaces after parameter name; 3 found - | | (MediaWiki.Commenting.FunctionComment.SpacingAfterParamName) - 31 | ERROR | [x] Short type of "bool" should be used for @param tag - | | (MediaWiki.Commenting.FunctionComment.NotShortBoolParam) - 32 | ERROR | [x] Short type of "int" should be used for @param tag - | | (MediaWiki.Commenting.FunctionComment.NotShortIntParam) - 33 | ERROR | [x] Short type of "bool" should be used for @return tag - | | (MediaWiki.Commenting.FunctionComment.NotShortBoolReturn) - 40 | ERROR | [x] Short type of "int" should be used for @return tag - | | (MediaWiki.Commenting.FunctionComment.NotShortIntReturn) - 49 | ERROR | [ ] Missing @return tag in function comment - | | (MediaWiki.Commenting.FunctionComment.MissingReturn) - 59 | ERROR | [ ] Missing parameter comment - | | (MediaWiki.Commenting.FunctionComment.MissingParamComment) - 59 | ERROR | [x] Short type of "bool" should be used for @param tag - | | (MediaWiki.Commenting.FunctionComment.NotShortBoolParam) - 60 | ERROR | [ ] Missing parameter comment - | | (MediaWiki.Commenting.FunctionComment.MissingParamComment) - 60 | ERROR | [x] Short type of "int" should be used for @param tag - | | (MediaWiki.Commenting.FunctionComment.NotShortIntParam) - 61 | ERROR | [x] Short type of "bool" should be used for @return tag - | | (MediaWiki.Commenting.FunctionComment.NotShortBoolReturn) - + 5 | ERROR | [ ] Missing function doc comment + | | (MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic) + 9 | ERROR | [ ] Missing function doc comment + | | (MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic) + 16 | ERROR | [ ] Missing @return tag in function comment + | | (MediaWiki.Commenting.FunctionComment.MissingReturn) + 22 | ERROR | [x] Expected 1 spaces after parameter name; 2 found + | | (MediaWiki.Commenting.FunctionComment.SpacingAfterParamName) + 23 | ERROR | [x] Expected 1 spaces after parameter name; 3 found + | | (MediaWiki.Commenting.FunctionComment.SpacingAfterParamName) + 31 | ERROR | [x] Short type of "bool" should be used for @param tag + | | (MediaWiki.Commenting.FunctionComment.NotShortBoolParam) + 32 | ERROR | [x] Short type of "int" should be used for @param tag + | | (MediaWiki.Commenting.FunctionComment.NotShortIntParam) + 33 | ERROR | [x] Short type of "bool" should be used for @return + | | tag + | | (MediaWiki.Commenting.FunctionComment.NotShortBoolReturn) + 40 | ERROR | [x] Short type of "int" should be used for @return tag + | | (MediaWiki.Commenting.FunctionComment.NotShortIntReturn) + 49 | ERROR | [ ] Missing @return tag in function comment + | | (MediaWiki.Commenting.FunctionComment.MissingReturn) + 59 | ERROR | [ ] Missing parameter comment + | | (MediaWiki.Commenting.FunctionComment.MissingParamComment) + 59 | ERROR | [x] Short type of "bool" should be used for @param tag + | | (MediaWiki.Commenting.FunctionComment.NotShortBoolParam) + 60 | ERROR | [ ] Missing parameter comment + | | (MediaWiki.Commenting.FunctionComment.MissingParamComment) + 60 | ERROR | [x] Short type of "int" should be used for @param tag + | | (MediaWiki.Commenting.FunctionComment.NotShortIntParam) + 61 | ERROR | [x] Short type of "bool" should be used for @return + | | tag + | | (MediaWiki.Commenting.FunctionComment.NotShortBoolReturn) + 68 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) + 135 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY diff --git a/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect b/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect index b6a64b9..8c1d88d 100644 --- a/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect +++ b/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect @@ -1,9 +1,15 @@ 16 | WARNING | Should use function $this->msg() rather than function | | wfMessage() . | | (MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage) + 27 | ERROR | Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) + 51 | ERROR | Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) 64 | WARNING | Should use function $this->getUser() rather than variable | | $wgUser . | | (MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage) + 75 | ERROR | Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) 93 | WARNING | Should use function $this->getRequest() rather than | | variable $wgRequest . - | | (MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage) \ No newline at end of file + | | (MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage) diff --git a/MediaWiki/Tests/files/WhiteSpace/space_before_class_brace.php.expect b/MediaWiki/Tests/files/WhiteSpace/space_before_class_brace.php.expect index 7691c47..97fec00 100644 --- a/MediaWiki/Tests/files/WhiteSpace/space_before_class_brace.php.expect +++ b/MediaWiki/Tests/files/WhiteSpace/space_before_class_brace.php.expect @@ -1,15 +1,27 @@ 6 | WARNING | [x] Expected 1 space before class open brace and should | | be same line.find 0 | | (MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace) + 13 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) 13 | WARNING | [x] Expected 1 space before class open brace and should | | be same line.find 2 | | (MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace) + 20 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) 21 | WARNING | [x] Expected 1 space before class open brace and should | | be same line.find 1 | | (MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace) + 25 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) + 29 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) 29 | WARNING | [x] Expected 1 space before class open brace and should | | be same line.find 0 | | (MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace) + 33 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) + 39 | ERROR | [ ] Only one class is allowed in a file + | | (Generic.Files.OneClassPerFile.MultipleFound) 41 | WARNING | [x] Expected class open brace to be on a new line | | (MediaWiki.WhiteSpace.SpaceBeforeClassBrace.BraceNotOnOwnLine) PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY diff --git a/MediaWiki/ruleset.xml b/MediaWiki/ruleset.xml index b12a7da..cbbbbe5 100644 --- a/MediaWiki/ruleset.xml +++ b/MediaWiki/ruleset.xml @@ -74,6 +74,11 @@ <rule ref="Generic.PHP.SAPIUsage" /> <rule ref="Generic.WhiteSpace.DisallowSpaceIndent" /> + <!-- One class per file --> + <rule ref="Generic.Files.OneClassPerFile" /> + <rule ref="Generic.Files.OneInterfacePerFile" /> + <rule ref="Generic.Files.OneTraitPerFile" /> + <rule ref="PSR2.Classes.PropertyDeclaration" /> <rule ref="PSR2.Classes.PropertyDeclaration.Multiple"> <!-- We tends to declare multiple properties with one statement --> -- To view, visit https://gerrit.wikimedia.org/r/372916 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I385b8758cc15171ed925df417304669bb6b0f9e6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/tools/codesniffer Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits