@critiq/rules 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +3 -2
  2. package/catalog.yaml +798 -0
  3. package/package.json +1 -1
  4. package/rules/cfn/cfn.correctness.attributedefinitions-keyschemas-mismatch.rule.yaml +49 -0
  5. package/rules/cfn/cfn.correctness.base64-validation-of-parameters.rule.yaml +49 -0
  6. package/rules/cfn/cfn.correctness.basic-cloudformation-resource-check.rule.yaml +49 -0
  7. package/rules/cfn/cfn.correctness.basic-cloudformation-template-configuration.rule.yaml +49 -0
  8. package/rules/cfn/cfn.correctness.cannot-reference-resources-in-the-conditions-block-of-the-template.rule.yaml +49 -0
  9. package/rules/cfn/cfn.correctness.check-at-least-one-essential-container-is-specified.rule.yaml +49 -0
  10. package/rules/cfn/cfn.correctness.check-deletionpolicy-values-for-resources.rule.yaml +49 -0
  11. package/rules/cfn/cfn.correctness.check-dependson-values-for-resources.rule.yaml +49 -0
  12. package/rules/cfn/cfn.correctness.check-ec2-ebs-properties.rule.yaml +49 -0
  13. package/rules/cfn/cfn.correctness.check-elastic-cache-redis-cluster-settings.rule.yaml +49 -0
  14. package/rules/cfn/cfn.correctness.check-events-rule-targets-are-less-than-or-equal-to-5.rule.yaml +49 -0
  15. package/rules/cfn/cfn.correctness.check-fargate-service-scheduling-strategy.rule.yaml +49 -0
  16. package/rules/cfn/cfn.correctness.check-fn-and-structure-for-validity.rule.yaml +49 -0
  17. package/rules/cfn/cfn.correctness.check-fn-equals-structure-for-validity.rule.yaml +49 -0
  18. package/rules/cfn/cfn.correctness.check-fn-if-structure-for-validity.rule.yaml +49 -0
  19. package/rules/cfn/cfn.correctness.check-fn-not-structure-for-validity.rule.yaml +49 -0
  20. package/rules/cfn/cfn.correctness.check-fn-or-structure-for-validity.rule.yaml +49 -0
  21. package/rules/cfn/cfn.correctness.check-for-subscriptionfilters-have-beyond-2-attachments-to-a-cloudwatch-log-group.rule.yaml +49 -0
  22. package/rules/cfn/cfn.correctness.check-if-a-json-object-is-within-size-limits.rule.yaml +49 -0
  23. package/rules/cfn/cfn.correctness.check-if-a-list-has-between-min-and-max-number-of-values-specified.rule.yaml +49 -0
  24. package/rules/cfn/cfn.correctness.check-if-a-list-has-duplicate-values.rule.yaml +49 -0
  25. package/rules/cfn/cfn.correctness.check-if-a-number-is-between-min-and-max.rule.yaml +49 -0
  26. package/rules/cfn/cfn.correctness.check-if-a-string-has-between-min-and-max-number-of-values-specified.rule.yaml +49 -0
  27. package/rules/cfn/cfn.correctness.check-if-eol-lambda-function-runtimes-are-used.rule.yaml +49 -0
  28. package/rules/cfn/cfn.correctness.check-if-properties-have-a-valid-value.rule.yaml +49 -0
  29. package/rules/cfn/cfn.correctness.check-if-property-values-adhere-to-a-specific-pattern.rule.yaml +49 -0
  30. package/rules/cfn/cfn.correctness.check-if-refing-to-a-iam-resource-with-path-set.rule.yaml +49 -0
  31. package/rules/cfn/cfn.correctness.check-if-refs-exist.rule.yaml +49 -0
  32. package/rules/cfn/cfn.correctness.check-if-serverless-resources-have-serverless-transform.rule.yaml +49 -0
  33. package/rules/cfn/cfn.correctness.check-if-the-referenced-conditions-are-defined.rule.yaml +49 -0
  34. package/rules/cfn/cfn.correctness.check-minimum-90-period-is-met-between-backupplan-cold-and-delete.rule.yaml +49 -0
  35. package/rules/cfn/cfn.correctness.check-properties-that-are-mutually-exclusive.rule.yaml +49 -0
  36. package/rules/cfn/cfn.correctness.check-properties-that-are-required-together.rule.yaml +49 -0
  37. package/rules/cfn/cfn.correctness.check-properties-that-need-at-least-one-of-a-list-of-properties.rule.yaml +49 -0
  38. package/rules/cfn/cfn.correctness.check-properties-that-need-only-one-of-a-list-of-properties.rule.yaml +49 -0
  39. package/rules/cfn/cfn.correctness.check-resource-properties-values.rule.yaml +49 -0
  40. package/rules/cfn/cfn.correctness.check-state-machine-definition-for-proper-syntax.rule.yaml +49 -0
  41. package/rules/cfn/cfn.correctness.check-that-modules-resources-are-valid.rule.yaml +49 -0
  42. package/rules/cfn/cfn.correctness.check-the-configuration-of-a-resources-updatepolicy.rule.yaml +49 -0
  43. package/rules/cfn/cfn.correctness.check-updatereplacepolicy-values-for-resources.rule.yaml +49 -0
  44. package/rules/cfn/cfn.correctness.check-values-of-properties-for-valid-refs-and-getatts.rule.yaml +49 -0
  45. package/rules/cfn/cfn.correctness.cidr-validation-of-parameters.rule.yaml +49 -0
  46. package/rules/cfn/cfn.correctness.cloudfront-aliases.rule.yaml +49 -0
  47. package/rules/cfn/cfn.correctness.codepipeline-stage-actions.rule.yaml +49 -0
  48. package/rules/cfn/cfn.correctness.codepipeline-stages.rule.yaml +49 -0
  49. package/rules/cfn/cfn.correctness.conditions-have-appropriate-properties.rule.yaml +49 -0
  50. package/rules/cfn/cfn.correctness.default-value-cannot-use-refs.rule.yaml +49 -0
  51. package/rules/cfn/cfn.correctness.default-value-is-within-parameter-constraints.rule.yaml +49 -0
  52. package/rules/cfn/cfn.correctness.error-processing-rule-on-the-template.rule.yaml +49 -0
  53. package/rules/cfn/cfn.correctness.findinmap-validation-of-configuration.rule.yaml +49 -0
  54. package/rules/cfn/cfn.correctness.getatt-validation-of-parameters.rule.yaml +49 -0
  55. package/rules/cfn/cfn.correctness.getaz-validation-of-parameters.rule.yaml +49 -0
  56. package/rules/cfn/cfn.correctness.importvalue-validation-of-parameters.rule.yaml +49 -0
  57. package/rules/cfn/cfn.correctness.join-validation-of-parameters.rule.yaml +49 -0
  58. package/rules/cfn/cfn.correctness.length-validation-of-parameters.rule.yaml +49 -0
  59. package/rules/cfn/cfn.correctness.mapping-attribute-limit-not-exceeded.rule.yaml +49 -0
  60. package/rules/cfn/cfn.correctness.mapping-keys-are-strings-and-alphanumeric.rule.yaml +49 -0
  61. package/rules/cfn/cfn.correctness.mapping-limit-not-exceeded.rule.yaml +49 -0
  62. package/rules/cfn/cfn.correctness.mapping-name-limit-not-exceeded.rule.yaml +49 -0
  63. package/rules/cfn/cfn.correctness.mappings-are-appropriately-configured.rule.yaml +49 -0
  64. package/rules/cfn/cfn.correctness.mappings-have-appropriate-names.rule.yaml +49 -0
  65. package/rules/cfn/cfn.correctness.metadata-interface-have-appropriate-properties.rule.yaml +49 -0
  66. package/rules/cfn/cfn.correctness.output-description-limit-not-exceeded.rule.yaml +49 -0
  67. package/rules/cfn/cfn.correctness.output-limit-not-exceeded.rule.yaml +49 -0
  68. package/rules/cfn/cfn.correctness.output-name-limit-not-exceeded.rule.yaml +49 -0
  69. package/rules/cfn/cfn.correctness.outputs-descriptions-can-only-be-strings.rule.yaml +49 -0
  70. package/rules/cfn/cfn.correctness.outputs-have-appropriate-names.rule.yaml +49 -0
  71. package/rules/cfn/cfn.correctness.outputs-have-appropriate-properties.rule.yaml +49 -0
  72. package/rules/cfn/cfn.correctness.outputs-have-required-properties.rule.yaml +49 -0
  73. package/rules/cfn/cfn.correctness.outputs-have-values-of-strings.rule.yaml +49 -0
  74. package/rules/cfn/cfn.correctness.parameter-limit-not-exceeded.rule.yaml +49 -0
  75. package/rules/cfn/cfn.correctness.parameter-name-limit-not-exceeded.rule.yaml +49 -0
  76. package/rules/cfn/cfn.correctness.parameter-value-limit-not-exceeded.rule.yaml +49 -0
  77. package/rules/cfn/cfn.correctness.parameters-have-appropriate-names.rule.yaml +49 -0
  78. package/rules/cfn/cfn.correctness.parameters-have-appropriate-properties.rule.yaml +49 -0
  79. package/rules/cfn/cfn.correctness.parameters-have-appropriate-type.rule.yaml +49 -0
  80. package/rules/cfn/cfn.correctness.property-is-required-based-on-another-properties-value.rule.yaml +49 -0
  81. package/rules/cfn/cfn.correctness.property-is-unwanted-based-on-another-properties-value.rule.yaml +49 -0
  82. package/rules/cfn/cfn.correctness.rds-instance-type-is-compatible-with-the-rds-type.rule.yaml +49 -0
  83. package/rules/cfn/cfn.correctness.recordset-hostedzonename-is-a-superdomain-of-name.rule.yaml +49 -0
  84. package/rules/cfn/cfn.correctness.ref-validation-of-value.rule.yaml +49 -0
  85. package/rules/cfn/cfn.correctness.required-resource-properties-are-missing.rule.yaml +49 -0
  86. package/rules/cfn/cfn.correctness.resource-dependencies-are-not-circular.rule.yaml +49 -0
  87. package/rules/cfn/cfn.correctness.resource-ec2-security-group-ingress-properties.rule.yaml +49 -0
  88. package/rules/cfn/cfn.correctness.resource-elb-properties.rule.yaml +49 -0
  89. package/rules/cfn/cfn.correctness.resource-limit-not-exceeded.rule.yaml +49 -0
  90. package/rules/cfn/cfn.correctness.resource-name-limit-not-exceeded.rule.yaml +49 -0
  91. package/rules/cfn/cfn.correctness.resource-properties-are-invalid.rule.yaml +49 -0
  92. package/rules/cfn/cfn.correctness.resource-schema.rule.yaml +49 -0
  93. package/rules/cfn/cfn.correctness.resource-subnetroutetableassociation-properties.rule.yaml +49 -0
  94. package/rules/cfn/cfn.correctness.resources-have-appropriate-names.rule.yaml +49 -0
  95. package/rules/cfn/cfn.correctness.select-validation-of-parameters.rule.yaml +49 -0
  96. package/rules/cfn/cfn.correctness.snapstart-supports-the-configured-runtime.rule.yaml +49 -0
  97. package/rules/cfn/cfn.correctness.split-validation-of-parameters.rule.yaml +49 -0
  98. package/rules/cfn/cfn.correctness.sub-is-required-if-a-variable-is-used-in-a-string.rule.yaml +49 -0
  99. package/rules/cfn/cfn.correctness.sub-validation-of-parameters.rule.yaml +49 -0
  100. package/rules/cfn/cfn.correctness.template-description-can-only-be-a-string.rule.yaml +49 -0
  101. package/rules/cfn/cfn.correctness.template-description-limit.rule.yaml +49 -0
  102. package/rules/cfn/cfn.correctness.template-size-limit.rule.yaml +49 -0
  103. package/rules/cfn/cfn.correctness.tojsonstring-validation-of-parameters.rule.yaml +49 -0
  104. package/rules/cfn/cfn.correctness.unique-resource-and-parameter-names.rule.yaml +49 -0
  105. package/rules/cfn/cfn.correctness.validate-accesscontrol-are-set-with-ownershipcontrols.rule.yaml +49 -0
  106. package/rules/cfn/cfn.correctness.validate-aws-event-scheduleexpression-format.rule.yaml +49 -0
  107. package/rules/cfn/cfn.correctness.validate-parameters-for-in-a-nested-stack.rule.yaml +49 -0
  108. package/rules/cfn/cfn.correctness.validate-route53-recordsets.rule.yaml +49 -0
  109. package/rules/cfn/cfn.correctness.validate-the-configuration-of-the-metadata-section.rule.yaml +49 -0
  110. package/rules/cfn/cfn.correctness.validates-foreach-functions.rule.yaml +49 -0
  111. package/rules/cfn/cfn.correctness.validation-not-function-configuration.rule.yaml +49 -0
  112. package/rules/cfn/cfn.correctness.validationdomain-is-superdomain-of-domainname.rule.yaml +49 -0
  113. package/rules/cfn/cfn.maintainability.arns-should-use-correctly-placed-pseudo-parameters.rule.yaml +49 -0
  114. package/rules/cfn/cfn.maintainability.availability-zone-parameters-should-not-be-hardcoded.rule.yaml +49 -0
  115. package/rules/cfn/cfn.maintainability.check-iam-resource-policies-syntax.rule.yaml +49 -0
  116. package/rules/cfn/cfn.maintainability.check-if-a-list-that-allows-duplicates-has-any-duplicates.rule.yaml +49 -0
  117. package/rules/cfn/cfn.maintainability.check-if-conditions-are-used.rule.yaml +49 -0
  118. package/rules/cfn/cfn.maintainability.check-if-eol-lambda-function-runtimes-are-used-w2531.rule.yaml +49 -0
  119. package/rules/cfn/cfn.maintainability.check-if-imageid-parameters-have-the-correct-type.rule.yaml +49 -0
  120. package/rules/cfn/cfn.maintainability.check-if-mappings-are-used.rule.yaml +49 -0
  121. package/rules/cfn/cfn.maintainability.check-if-parameters-are-used.rule.yaml +49 -0
  122. package/rules/cfn/cfn.maintainability.check-if-parameters-have-a-valid-value-based-on-an-allowed-pattern.rule.yaml +49 -0
  123. package/rules/cfn/cfn.maintainability.check-if-parameters-have-a-valid-value.rule.yaml +49 -0
  124. package/rules/cfn/cfn.maintainability.check-obsolete-dependson-configuration-for-resources.rule.yaml +49 -0
  125. package/rules/cfn/cfn.maintainability.check-outputs-using-importvalue.rule.yaml +49 -0
  126. package/rules/cfn/cfn.maintainability.check-required-properties-for-lambda-if-the-deployment-package-is-a-zip-file.rule.yaml +49 -0
  127. package/rules/cfn/cfn.maintainability.check-resources-with-auto-expiring-content-have-explicit-retention-period.rule.yaml +49 -0
  128. package/rules/cfn/cfn.maintainability.check-resources-with-updatereplacepolicy-deletionpolicy-have-both.rule.yaml +49 -0
  129. package/rules/cfn/cfn.maintainability.check-stateful-resources-have-a-set-updatereplacepolicy-deletionpolicy.rule.yaml +49 -0
  130. package/rules/cfn/cfn.maintainability.checks-for-legacy-instance-type-generations.rule.yaml +49 -0
  131. package/rules/cfn/cfn.maintainability.findinmap-keys-exist-in-the-map.rule.yaml +49 -0
  132. package/rules/cfn/cfn.maintainability.fn-equals-will-always-return-true-or-false.rule.yaml +49 -0
  133. package/rules/cfn/cfn.maintainability.mapping-attribute-limit.rule.yaml +49 -0
  134. package/rules/cfn/cfn.maintainability.mapping-limit.rule.yaml +49 -0
  135. package/rules/cfn/cfn.maintainability.mapping-name-limit.rule.yaml +49 -0
  136. package/rules/cfn/cfn.maintainability.metadata-interface-parameters-exist.rule.yaml +49 -0
  137. package/rules/cfn/cfn.maintainability.output-description-limit.rule.yaml +49 -0
  138. package/rules/cfn/cfn.maintainability.output-limit.rule.yaml +49 -0
  139. package/rules/cfn/cfn.maintainability.output-name-limit.rule.yaml +49 -0
  140. package/rules/cfn/cfn.maintainability.parameter-limit.rule.yaml +49 -0
  141. package/rules/cfn/cfn.maintainability.parameter-memory-size-attributes-should-have-max-and-min.rule.yaml +49 -0
  142. package/rules/cfn/cfn.maintainability.parameter-name-limit.rule.yaml +49 -0
  143. package/rules/cfn/cfn.maintainability.parameter-value-limit.rule.yaml +49 -0
  144. package/rules/cfn/cfn.maintainability.ref-getatt-to-resource-that-is-available-when-conditions-are-applied.rule.yaml +49 -0
  145. package/rules/cfn/cfn.maintainability.resource-limit.rule.yaml +49 -0
  146. package/rules/cfn/cfn.maintainability.resource-name-limit.rule.yaml +49 -0
  147. package/rules/cfn/cfn.maintainability.sub-isn-t-needed-if-it-doesn-t-have-a-variable-defined.rule.yaml +49 -0
  148. package/rules/cfn/cfn.maintainability.sub-validation-of-parameters-w1019.rule.yaml +49 -0
  149. package/rules/cfn/cfn.maintainability.template-description-limit-i1003.rule.yaml +49 -0
  150. package/rules/cfn/cfn.maintainability.template-size-limit-i1002.rule.yaml +49 -0
  151. package/rules/cfn/cfn.maintainability.use-sub-instead-of-join.rule.yaml +49 -0
  152. package/rules/cfn/cfn.maintainability.validate-that-snapstart-is-configured-for-java11-runtimes.rule.yaml +49 -0
  153. package/rules/cfn/cfn.maintainability.validate-that-snapstart-is-properly-configured.rule.yaml +49 -0
  154. package/rules/cfn/cfn.maintainability.warn-when-properties-are-configured-to-only-work-with-the-package-command.rule.yaml +49 -0
  155. package/rules/cfn/cfn.security.check-dynamic-references-secure-strings-are-in-supported-locations.rule.yaml +53 -0
  156. package/rules/cfn/cfn.security.check-for-noecho-references.rule.yaml +53 -0
  157. package/rules/cfn/cfn.security.check-iam-permission-configuration.rule.yaml +53 -0
  158. package/rules/cfn/cfn.security.check-if-iam-policies-are-properly-configured.rule.yaml +53 -0
  159. package/rules/cfn/cfn.security.check-if-password-properties-are-correctly-configured.rule.yaml +53 -0
  160. package/rules/cfn/cfn.security.controlling-access-to-an-s3-bucket-should-be-done-with-bucket-policies.rule.yaml +53 -0
  161. package/rules/php/php.correctness.abstract-method-outside-abstract-class.rule.yaml +36 -0
  162. package/rules/php/php.correctness.break-continue-outside-loop.rule.yaml +36 -0
  163. package/rules/php/php.correctness.case-insensitive-define.rule.yaml +36 -0
  164. package/rules/php/php.correctness.default-parameter-not-last.rule.yaml +36 -0
  165. package/rules/php/php.correctness.deprecated-filter-constant.rule.yaml +36 -0
  166. package/rules/php/php.correctness.deprecated-libxml-entity-loader.rule.yaml +36 -0
  167. package/rules/php/php.correctness.deprecated-unset-cast.rule.yaml +36 -0
  168. package/rules/php/php.correctness.duplicate-declaration.rule.yaml +36 -0
  169. package/rules/php/php.correctness.empty-array-literal-slot.rule.yaml +36 -0
  170. package/rules/php/php.correctness.empty-bracket-array-access.rule.yaml +36 -0
  171. package/rules/php/php.correctness.empty-code-block.rule.yaml +36 -0
  172. package/rules/php/php.correctness.empty-function-body.rule.yaml +36 -0
  173. package/rules/php/php.correctness.function-comparison.rule.yaml +36 -0
  174. package/rules/php/php.correctness.invalid-cookie-options.rule.yaml +36 -0
  175. package/rules/php/php.correctness.invalid-regex-literal.rule.yaml +36 -0
  176. package/rules/php/php.correctness.missing-member-visibility.rule.yaml +36 -0
  177. package/rules/php/php.correctness.nested-function-declaration.rule.yaml +36 -0
  178. package/rules/php/php.correctness.nested-switch.rule.yaml +36 -0
  179. package/rules/php/php.correctness.redundant-string-cast-concat.rule.yaml +36 -0
  180. package/rules/php/php.correctness.self-assignment.rule.yaml +36 -0
  181. package/rules/php/php.correctness.todo-fixme-marker.rule.yaml +36 -0
  182. package/rules/php/php.correctness.unknown-magic-method.rule.yaml +36 -0
  183. package/rules/php/php.correctness.useless-post-increment.rule.yaml +36 -0
  184. package/rules/php/php.correctness.useless-unset.rule.yaml +36 -0
  185. package/rules/php/php.performance.expensive-loop-condition.rule.yaml +36 -0
  186. package/rules/php/php.security.unsafe-new-static.rule.yaml +42 -0
  187. package/rules/ruby/ruby.bug-risk.assignment-in-condition.rule.yaml +42 -0
  188. package/rules/ruby/ruby.bug-risk.deprecated-uri-escape.rule.yaml +42 -0
  189. package/rules/ruby/ruby.bug-risk.division-by-zero.rule.yaml +42 -0
  190. package/rules/ruby/ruby.bug-risk.duplicate-hash-keys.rule.yaml +42 -0
  191. package/rules/ruby/ruby.bug-risk.exception-class-overwritten.rule.yaml +42 -0
  192. package/rules/ruby/ruby.bug-risk.raw-sql-without-squish.rule.yaml +42 -0
  193. package/rules/ruby/ruby.security.debugger-call.rule.yaml +53 -0
  194. package/rules/ruby/ruby.security.dynamic-code-execution.rule.yaml +54 -0
  195. package/rules/ruby/ruby.security.insecure-json-load.rule.yaml +53 -0
  196. package/rules/ruby/ruby.security.kernel-open.rule.yaml +53 -0
  197. package/rules/ruby/ruby.security.plaintext-password-in-callback.rule.yaml +46 -0
  198. package/rules/ruby/ruby.security.rails-link-to-blank-without-noopener.rule.yaml +48 -0
  199. package/rules/ruby/ruby.security.rails-output-unsafe.rule.yaml +47 -0
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.invalid-regex-literal
5
+ title: Fix invalid regular expression literals
6
+ summary: preg_* calls must use a valid delimiter and closing pattern literal.
7
+ rationale: Invalid regex literals fail at runtime and often hide copy-paste or escaping mistakes.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.invalid-regex-literal
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: medium
28
+ confidence: 0.9
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Fix invalid regular expression literals
34
+ summary: "`${captures.issue.text}` matches php.correctness.invalid-regex-literal."
35
+ remediation:
36
+ summary: Invalid regex literals fail at runtime and often hide copy-paste or escaping mistakes.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.missing-member-visibility
5
+ title: Declare explicit member visibility
6
+ summary: Class properties and methods should declare public, protected, or private visibility.
7
+ rationale: Missing visibility relies on legacy defaults and makes class contracts harder to review.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: experimental
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.missing-member-visibility
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: low
28
+ confidence: 0.55
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Declare explicit member visibility
34
+ summary: "`${captures.issue.text}` matches php.correctness.missing-member-visibility."
35
+ remediation:
36
+ summary: Missing visibility relies on legacy defaults and makes class contracts harder to review.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.nested-function-declaration
5
+ title: Avoid nested function declarations
6
+ summary: Declaring functions inside other functions is discouraged and hard to test.
7
+ rationale: Nested functions create hidden scope and make code harder to reuse, mock, and reason about.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.nested-function-declaration
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: low
28
+ confidence: 0.9
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Avoid nested function declarations
34
+ summary: "`${captures.issue.text}` matches php.correctness.nested-function-declaration."
35
+ remediation:
36
+ summary: Nested functions create hidden scope and make code harder to reuse, mock, and reason about.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.nested-switch
5
+ title: Avoid nested switch statements
6
+ summary: Switch statements nested inside other switch statements are hard to follow.
7
+ rationale: Nested switch blocks increase cognitive load and often hide missing decomposition or polymorphism.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.nested-switch
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.control-flow
27
+ severity: low
28
+ confidence: 0.9
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Avoid nested switch statements
34
+ summary: "`${captures.issue.text}` matches php.correctness.nested-switch."
35
+ remediation:
36
+ summary: Nested switch blocks increase cognitive load and often hide missing decomposition or polymorphism.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.redundant-string-cast-concat
5
+ title: Remove redundant string casts before concatenation
6
+ summary: Casting to string immediately before concatenation is usually redundant in PHP.
7
+ rationale: Redundant casts add noise without changing behavior and can hide type problems that should be fixed directly.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.redundant-string-cast-concat
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: low
28
+ confidence: 0.9
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Remove redundant string casts before concatenation
34
+ summary: "`${captures.issue.text}` matches php.correctness.redundant-string-cast-concat."
35
+ remediation:
36
+ summary: Redundant casts add noise without changing behavior and can hide type problems that should be fixed directly.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.self-assignment
5
+ title: Remove self assignments
6
+ summary: Assigning a variable to itself has no effect.
7
+ rationale: Self assignments usually indicate incomplete refactors or accidental duplication.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.self-assignment
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: low
28
+ confidence: 0.95
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Remove self assignments
34
+ summary: "`${captures.issue.text}` matches php.correctness.self-assignment."
35
+ remediation:
36
+ summary: Self assignments usually indicate incomplete refactors or accidental duplication.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.todo-fixme-marker
5
+ title: Resolve TODO or FIXME markers
6
+ summary: TODO, FIXME, XXX, and HACK comments mark unfinished or risky work.
7
+ rationale: Tracked markers in production code often hide deferred fixes that should be ticketed or resolved before merge.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.todo-fixme-marker
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.maintainability
27
+ severity: low
28
+ confidence: 0.95
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Resolve TODO or FIXME markers
34
+ summary: "`${captures.issue.text}` matches php.correctness.todo-fixme-marker."
35
+ remediation:
36
+ summary: Tracked markers in production code often hide deferred fixes that should be ticketed or resolved before merge.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.unknown-magic-method
5
+ title: Use only supported magic methods
6
+ summary: PHP recognizes a fixed set of double-underscore magic methods.
7
+ rationale: Unknown magic methods are never invoked by the runtime and usually indicate typos or dead code.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.unknown-magic-method
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: medium
28
+ confidence: 0.95
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Use only supported magic methods
34
+ summary: "`${captures.issue.text}` matches php.correctness.unknown-magic-method."
35
+ remediation:
36
+ summary: Unknown magic methods are never invoked by the runtime and usually indicate typos or dead code.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.useless-post-increment
5
+ title: Remove useless post-increment statements
6
+ summary: Standalone post-increment statements with discarded results are usually mistakes.
7
+ rationale: Post-increment statements that do not feed a larger expression often indicate dead or accidental code.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.useless-post-increment
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: low
28
+ confidence: 0.85
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Remove useless post-increment statements
34
+ summary: "`${captures.issue.text}` matches php.correctness.useless-post-increment."
35
+ remediation:
36
+ summary: Post-increment statements that do not feed a larger expression often indicate dead or accidental code.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.correctness.useless-unset
5
+ title: Remove useless unset calls
6
+ summary: Calling unset on literals or non-variables has no effect.
7
+ rationale: Useless unset calls add noise and suggest the author misunderstood PHP unset semantics.
8
+ tags:
9
+ - correctness
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.correctness.useless-unset
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: correctness.language
27
+ severity: low
28
+ confidence: 0.9
29
+ tags:
30
+ - correctness
31
+ - php
32
+ message:
33
+ title: Remove useless unset calls
34
+ summary: "`${captures.issue.text}` matches php.correctness.useless-unset."
35
+ remediation:
36
+ summary: Useless unset calls add noise and suggest the author misunderstood PHP unset semantics.
@@ -0,0 +1,36 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.performance.expensive-loop-condition
5
+ title: Avoid expensive calls in loop conditions
6
+ summary: Functions like count() and strlen() inside loop conditions run on every iteration.
7
+ rationale: Recomputing expensive conditions in loops adds avoidable overhead in hot paths.
8
+ tags:
9
+ - performance
10
+ - php
11
+ - rules-catalog
12
+ stability: stable
13
+ appliesTo: block
14
+ scope:
15
+ languages:
16
+ - php
17
+ paths:
18
+ include:
19
+ - "**/*.php"
20
+ match:
21
+ fact:
22
+ kind: php.performance.expensive-loop-condition
23
+ bind: issue
24
+ emit:
25
+ finding:
26
+ category: performance.allocation
27
+ severity: medium
28
+ confidence: 0.85
29
+ tags:
30
+ - performance
31
+ - php
32
+ message:
33
+ title: Avoid expensive calls in loop conditions
34
+ summary: "`${captures.issue.text}` matches php.performance.expensive-loop-condition."
35
+ remediation:
36
+ summary: Recomputing expensive conditions in loops adds avoidable overhead in hot paths.
@@ -0,0 +1,42 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: php.security.unsafe-new-static
5
+ title: Avoid unsafe new static() instantiation
6
+ summary: "Using `new static()` can instantiate unexpected subclasses and weaken type guarantees."
7
+ rationale: "Late static binding with `new static()` can bypass intended class boundaries and create objects outside expected inheritance chains."
8
+ detection:
9
+ kind: pattern
10
+ references:
11
+ - kind: cwe
12
+ id: CWE-470
13
+ title: Use of Externally-Controlled Input to Select Classes or Code
14
+ tags:
15
+ - security
16
+ - php
17
+ - rules-catalog
18
+ stability: stable
19
+ appliesTo: block
20
+ scope:
21
+ languages:
22
+ - php
23
+ paths:
24
+ include:
25
+ - "**/*.php"
26
+ match:
27
+ fact:
28
+ kind: php.security.unsafe-new-static
29
+ bind: issue
30
+ emit:
31
+ finding:
32
+ category: security.injection
33
+ severity: medium
34
+ confidence: 0.88
35
+ tags:
36
+ - security
37
+ - php
38
+ message:
39
+ title: Avoid unsafe new static() instantiation
40
+ summary: "`${captures.issue.text}` matches php.security.unsafe-new-static."
41
+ remediation:
42
+ summary: "Late static binding with `new static()` can bypass intended class boundaries and create objects outside expected inheritance chains."
@@ -0,0 +1,42 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: ruby.bug-risk.assignment-in-condition
5
+ title: Avoid assignment inside conditionals
6
+ summary: >-
7
+ Extract assignments from if, unless, while, and until conditions.
8
+ rationale: >-
9
+ Assignment in conditions is easy to mistake for comparison.
10
+ detection:
11
+ kind: pattern
12
+ tags:
13
+ - rules-catalog
14
+ - ruby
15
+ stability: stable
16
+ appliesTo: block
17
+ scope:
18
+ languages:
19
+ - ruby
20
+ paths:
21
+ include:
22
+ - "**/*.rb"
23
+ exclude:
24
+ - "**/vendor/**"
25
+ - "**/node_modules/**"
26
+ match:
27
+ fact:
28
+ kind: ruby.bug-risk.assignment-in-condition
29
+ bind: issue
30
+ emit:
31
+ finding:
32
+ category: correctness.language
33
+ severity: medium
34
+ confidence: 0.9
35
+ tags:
36
+ - ruby
37
+ message:
38
+ title: Review `${captures.issue.text}`
39
+ summary: "`${captures.issue.text}` matches `ruby.bug-risk.assignment-in-condition`."
40
+ remediation:
41
+ summary: >-
42
+ Extract assignments from if, unless, while, and until conditions.
@@ -0,0 +1,42 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: ruby.bug-risk.deprecated-uri-escape
5
+ title: Avoid deprecated URI.escape helpers
6
+ summary: >-
7
+ Use CGI.escape, URI.encode_www_form_component, or Addressable instead.
8
+ rationale: >-
9
+ URI.escape and URI.unescape are deprecated and removed in modern Ruby.
10
+ detection:
11
+ kind: pattern
12
+ tags:
13
+ - rules-catalog
14
+ - ruby
15
+ stability: stable
16
+ appliesTo: block
17
+ scope:
18
+ languages:
19
+ - ruby
20
+ paths:
21
+ include:
22
+ - "**/*.rb"
23
+ exclude:
24
+ - "**/vendor/**"
25
+ - "**/node_modules/**"
26
+ match:
27
+ fact:
28
+ kind: ruby.bug-risk.deprecated-uri-escape
29
+ bind: issue
30
+ emit:
31
+ finding:
32
+ category: correctness.language
33
+ severity: low
34
+ confidence: 0.9
35
+ tags:
36
+ - ruby
37
+ message:
38
+ title: Review `${captures.issue.text}`
39
+ summary: "`${captures.issue.text}` matches `ruby.bug-risk.deprecated-uri-escape`."
40
+ remediation:
41
+ summary: >-
42
+ Use CGI.escape, URI.encode_www_form_component, or Addressable instead.
@@ -0,0 +1,42 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: ruby.bug-risk.division-by-zero
5
+ title: Avoid division by zero literals
6
+ summary: >-
7
+ Do not divide by literal zero.
8
+ rationale: >-
9
+ Division by zero raises ZeroDivisionError at runtime.
10
+ detection:
11
+ kind: pattern
12
+ tags:
13
+ - rules-catalog
14
+ - ruby
15
+ stability: stable
16
+ appliesTo: block
17
+ scope:
18
+ languages:
19
+ - ruby
20
+ paths:
21
+ include:
22
+ - "**/*.rb"
23
+ exclude:
24
+ - "**/vendor/**"
25
+ - "**/node_modules/**"
26
+ match:
27
+ fact:
28
+ kind: ruby.bug-risk.division-by-zero
29
+ bind: issue
30
+ emit:
31
+ finding:
32
+ category: correctness.language
33
+ severity: medium
34
+ confidence: 0.9
35
+ tags:
36
+ - ruby
37
+ message:
38
+ title: Review `${captures.issue.text}`
39
+ summary: "`${captures.issue.text}` matches `ruby.bug-risk.division-by-zero`."
40
+ remediation:
41
+ summary: >-
42
+ Do not divide by literal zero.
@@ -0,0 +1,42 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: ruby.bug-risk.duplicate-hash-keys
5
+ title: Avoid duplicate keys in hash literals
6
+ summary: >-
7
+ Remove duplicate symbol or string keys in the same hash literal.
8
+ rationale: >-
9
+ Later duplicate keys silently override earlier entries.
10
+ detection:
11
+ kind: pattern
12
+ tags:
13
+ - rules-catalog
14
+ - ruby
15
+ stability: stable
16
+ appliesTo: block
17
+ scope:
18
+ languages:
19
+ - ruby
20
+ paths:
21
+ include:
22
+ - "**/*.rb"
23
+ exclude:
24
+ - "**/vendor/**"
25
+ - "**/node_modules/**"
26
+ match:
27
+ fact:
28
+ kind: ruby.bug-risk.duplicate-hash-keys
29
+ bind: issue
30
+ emit:
31
+ finding:
32
+ category: correctness.language
33
+ severity: medium
34
+ confidence: 0.9
35
+ tags:
36
+ - ruby
37
+ message:
38
+ title: Review `${captures.issue.text}`
39
+ summary: "`${captures.issue.text}` matches `ruby.bug-risk.duplicate-hash-keys`."
40
+ remediation:
41
+ summary: >-
42
+ Remove duplicate symbol or string keys in the same hash literal.
@@ -0,0 +1,42 @@
1
+ apiVersion: critiq.dev/v1alpha1
2
+ kind: Rule
3
+ metadata:
4
+ id: ruby.bug-risk.exception-class-overwritten
5
+ title: Do not assign rescue result to exception class names
6
+ summary: >-
7
+ Use rescue StandardError or rescue StandardError => e, not rescue => StandardError.
8
+ rationale: >-
9
+ rescue => StandardError shadows the exception class with the rescued value.
10
+ detection:
11
+ kind: pattern
12
+ tags:
13
+ - rules-catalog
14
+ - ruby
15
+ stability: stable
16
+ appliesTo: block
17
+ scope:
18
+ languages:
19
+ - ruby
20
+ paths:
21
+ include:
22
+ - "**/*.rb"
23
+ exclude:
24
+ - "**/vendor/**"
25
+ - "**/node_modules/**"
26
+ match:
27
+ fact:
28
+ kind: ruby.bug-risk.exception-class-overwritten
29
+ bind: issue
30
+ emit:
31
+ finding:
32
+ category: correctness.language
33
+ severity: medium
34
+ confidence: 0.9
35
+ tags:
36
+ - ruby
37
+ message:
38
+ title: Review `${captures.issue.text}`
39
+ summary: "`${captures.issue.text}` matches `ruby.bug-risk.exception-class-overwritten`."
40
+ remediation:
41
+ summary: >-
42
+ Use rescue StandardError or rescue StandardError => e, not rescue => StandardError.