Skip to content

Commit

Permalink
add vaimo phpcs-rulesets (#317)
Browse files Browse the repository at this point in the history
* add vaimo phpcs-rulesets
  • Loading branch information
DMarinhoCodacy authored Feb 3, 2025
1 parent 91192f9 commit 79e1765
Showing 28 changed files with 452 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
"doctrine/coding-standard": "^12.0.0",
"drupal/coder": "^8.3.24",
"escapestudios/symfony2-coding-standard": "^3.13.0",
"magento/magento-coding-standard": "^32.0",
"magento/magento-coding-standard": "32.0",
"magento/marketplace-eqp": "^4.0.0",
"pheromone/phpcs-security-audit": "^2.0.1",
"phpcompatibility/php-compatibility": "9.3.5",
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ class Generator() {
new PHPCSSecurityAuditDocsParser(),
new SlevomatCSDocsParser(),
new SymfonyDocsParser(),
new VaimoParser(),
new VaimoUKParser(),
new VipWordPressDocsParser(),
new WordPressCSDocsParser()
Original file line number Diff line number Diff line change
@@ -23,4 +23,5 @@ object VersionsHelper {
lazy val codesniffer = properties("squizlabs/php_codesniffer").str.replace("^","")
lazy val wordpress = properties("wp-coding-standards/wpcs").str.replace("^","")
lazy val vaimoUK = properties("vaimo/uk-phpcs-standards").str.replace("^","")
lazy val vaimo = properties("vaimo/phpcs-rulesets").str.replace("^","")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

package codacy.codesniffer.docsgen.parsers

import codacy.codesniffer.docsgen.VersionsHelper
import scala.util.matching.Regex

import better.files.File
import com.codacy.plugins.api.results.Pattern

import scala.annotation.nowarn

class VaimoParser extends DocsParser {

override val repositoryURL = "https://bitbucket.org/vaimo/phpcs-rulesets"

override val checkoutCommit: String = VersionsHelper.vaimo


override val sniffRegex: Regex = """.*(Vaimo)\/Sniffs\/(.*?)\/(.*?)Sniff.php""".r

@nowarn("msg=match may not be exhaustive")
override def patternIdPartsFor(relativizedFilePath: String): PatternIdParts = {
val sniffRegex(vaimoVersion, sniffType, patternName) = relativizedFilePath
PatternIdParts(vaimoVersion, sniffType, patternName)
}

override def descriptionWithDocs(rootDir: File,
patternIdParts: PatternIdParts,
patternFile: File
): (Pattern.Description, Option[String]) = {
(description(patternIdParts, rootDir),
this.parseExtendedDescription("Vaimo\\Sniffs\\Custom", "Vaimo", patternIdParts, rootDir)
)
}

private[this] def description(patternIdParts: PatternIdParts, rootDir: File): Pattern.Description = {
val caseRegexPattern = """((?<=\p{Ll})\p{Lu}|\p{Lu}(?=\p{Ll}))""".r
val patternName = caseRegexPattern.replaceAllIn(patternIdParts.patternName, " $1").trim
val sniffName = caseRegexPattern.replaceAllIn(patternIdParts.sniffType, " $1").trim
val title = Pattern.Title(s"$sniffName: $patternName")
val extended = this.parseDescription("Vaimo\\Sniffs\\Custom", "Vaimo", patternIdParts, rootDir)
Pattern.Description(patternIdParts.patternId, title, extended, None, Set.empty)
}
}

1 change: 1 addition & 0 deletions docs/description/CakePHP_Commenting_TypeHint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Commenting: Type Hint
1 change: 1 addition & 0 deletions docs/description/Vaimo_Classes_ConstantDeclarationOrder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Classes: Constant Declaration Order
1 change: 1 addition & 0 deletions docs/description/Vaimo_Classes_ObjectInstantiation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Classes: Object Instantiation
1 change: 1 addition & 0 deletions docs/description/Vaimo_Classes_PropertyUnderscore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Classes: Property Underscore
1 change: 1 addition & 0 deletions docs/description/Vaimo_Classes_ProtectedMember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Classes: Protected Member
1 change: 1 addition & 0 deletions docs/description/Vaimo_Classes_UndefinedProperty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Classes: Undefined Property
1 change: 1 addition & 0 deletions docs/description/Vaimo_CodeAnalysis_Copyright.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Code Analysis: Copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Code Analysis: Unused Function Parameter
1 change: 1 addition & 0 deletions docs/description/Vaimo_Comments_DeprecationNotice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Comments: Deprecation Notice
1 change: 1 addition & 0 deletions docs/description/Vaimo_ControlStructures_NestedIf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Control Structures: Nested If
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Control Structures: Ternary Operator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Control Structures: Ternary Operator Placement
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exceptions: Try Process System Resources
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: And Or In Class Name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: And Or In Method Name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: And Or In Variable Name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: Illegal Word In Class Name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: Illegal Word In Method Name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: Illegal Word In Variable Name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Naming Conventions: Variables Camel Case
1 change: 1 addition & 0 deletions docs/description/Vaimo_PHP_NoSilencedErrors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PHP: No Silenced Errors
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Type Hints: Illegal Return Type Annotation
162 changes: 158 additions & 4 deletions docs/description/description.json
Original file line number Diff line number Diff line change
@@ -9,14 +9,21 @@
}, {
"patternId" : "CakePHP_Commenting_FunctionComment",
"title" : "Commenting: Function Comment",
"parameters" : [ {
"name" : "minimumVisibility",
"description" : "minimumVisibility"
} ]
"parameters" : [ ]
}, {
"patternId" : "CakePHP_Commenting_InheritDoc",
"title" : "Commenting: Inherit Doc",
"parameters" : [ ]
}, {
"patternId" : "CakePHP_Commenting_TypeHint",
"title" : "Commenting: Type Hint",
"parameters" : [ {
"name" : "convertArraysToGenerics",
"description" : "convertArraysToGenerics"
}, {
"name" : "ignorePhpStormGenerics",
"description" : "ignorePhpStormGenerics"
} ]
}, {
"patternId" : "CakePHP_ControlStructures_ControlStructures",
"title" : "Control Structures: Control Structures",
@@ -4103,6 +4110,101 @@
"patternId" : "Symfony_Whitespace_DiscourageFitzinator",
"title" : "Whitespace: Discourage Fitzinator",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_Classes_ConstantDeclarationOrder",
"title" : "Classes: Constant Declaration Order",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_Classes_ObjectInstantiation",
"title" : "Classes: Object Instantiation",
"parameters" : [ {
"name" : "allowNamedConstructors",
"description" : "allowNamedConstructors"
}, {
"name" : "allowInstantiateFinalClasses",
"description" : "allowInstantiateFinalClasses"
}, {
"name" : "reportReflectionError",
"description" : "reportReflectionError"
}, {
"name" : "considerFinalInstantiationOnReflectionError",
"description" : "considerFinalInstantiationOnReflectionError"
}, {
"name" : "allowAnonymousClasses",
"description" : "allowAnonymousClasses"
} ]
}, {
"patternId" : "Vaimo_Classes_PropertyUnderscore",
"title" : "Classes: Property Underscore",
"parameters" : [ {
"name" : "allowInherited",
"description" : "allowInherited"
}, {
"name" : "skipOnReflectionError",
"description" : "skipOnReflectionError"
} ]
}, {
"patternId" : "Vaimo_Classes_ProtectedMember",
"title" : "Classes: Protected Member",
"parameters" : [ {
"name" : "considerInheritedOnReflectionError",
"description" : "considerInheritedOnReflectionError"
}, {
"name" : "allowAbstract",
"description" : "allowAbstract"
}, {
"name" : "allowProtectedPropertyInAbstractClass",
"description" : "allowProtectedPropertyInAbstractClass"
}, {
"name" : "allowProtectedFunctionInAbstractClass",
"description" : "allowProtectedFunctionInAbstractClass"
}, {
"name" : "allowInherited",
"description" : "allowInherited"
} ]
}, {
"patternId" : "Vaimo_Classes_UndefinedProperty",
"title" : "Classes: Undefined Property",
"parameters" : [ {
"name" : "skipOnReflectionError",
"description" : "skipOnReflectionError"
} ]
}, {
"patternId" : "Vaimo_CodeAnalysis_Copyright",
"title" : "Code Analysis: Copyright",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_CodeAnalysis_UnusedFunctionParameter",
"title" : "Code Analysis: Unused Function Parameter",
"parameters" : [ {
"name" : "allowUnusedInheritedParameters",
"description" : "allowUnusedInheritedParameters"
}, {
"name" : "considerInheritedOnReflectionError",
"description" : "considerInheritedOnReflectionError"
} ]
}, {
"patternId" : "Vaimo_Comments_DeprecationNotice",
"title" : "Comments: Deprecation Notice",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_ControlStructures_NestedIf",
"title" : "Control Structures: Nested If",
"parameters" : [ {
"name" : "maxAllowedNesting",
"description" : "maxAllowedNesting"
} ]
}, {
"patternId" : "Vaimo_ControlStructures_TernaryOperator",
"title" : "Control Structures: Ternary Operator",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_ControlStructures_TernaryOperatorPlacement",
"title" : "Control Structures: Ternary Operator Placement",
"parameters" : [ {
"name" : "allowOnly",
"description" : "allowOnly"
} ]
}, {
"patternId" : "Vaimo_Custom_ArrayAccess",
"title" : "Custom: Array Access",
@@ -4119,6 +4221,58 @@
"patternId" : "Vaimo_Custom_NoPhpCsDisable",
"title" : "Custom: No Php Cs Disable",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_Exceptions_TryProcessSystemResources",
"title" : "Exceptions: Try Process System Resources",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_NamingConventions_AndOrInClassName",
"title" : "Naming Conventions: And Or In Class Name",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_NamingConventions_AndOrInMethodName",
"title" : "Naming Conventions: And Or In Method Name",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_NamingConventions_AndOrInVariableName",
"title" : "Naming Conventions: And Or In Variable Name",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_NamingConventions_IllegalWordInClassName",
"title" : "Naming Conventions: Illegal Word In Class Name",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_NamingConventions_IllegalWordInMethodName",
"title" : "Naming Conventions: Illegal Word In Method Name",
"parameters" : [ {
"name" : "allowInheritedMethods",
"description" : "allowInheritedMethods"
}, {
"name" : "considerInheritedOnReflectionError",
"description" : "considerInheritedOnReflectionError"
} ]
}, {
"patternId" : "Vaimo_NamingConventions_IllegalWordInVariableName",
"title" : "Naming Conventions: Illegal Word In Variable Name",
"parameters" : [ {
"name" : "allowInheritedProperties",
"description" : "allowInheritedProperties"
}, {
"name" : "considerInheritedOnReflectionError",
"description" : "considerInheritedOnReflectionError"
} ]
}, {
"patternId" : "Vaimo_NamingConventions_VariablesCamelCase",
"title" : "Naming Conventions: Variables Camel Case",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_PHP_NoSilencedErrors",
"title" : "PHP: No Silenced Errors",
"parameters" : [ ]
}, {
"patternId" : "Vaimo_TypeHints_IllegalReturnTypeAnnotation",
"title" : "Type Hints: Illegal Return Type Annotation",
"parameters" : [ ]
}, {
"patternId" : "WordPressVIPMinimum_Classes_DeclarationCompatibility",
"title" : "Classes: Declaration Compatibility",
Loading
Oops, something went wrong.

0 comments on commit 79e1765

Please sign in to comment.