Skip to content

Generic.Commenting.Todo.CommentFound sample not working #3769

Open
PHPCSStandards/PHP_CodeSniffer
#53
@davidsneighbour

Description

@davidsneighbour

Describe the bug

I configured my Generic.Commenting.Todo.CommentFound setup according to the docs in the wiki..

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Booka" namespace="Booka">
  <!-- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset -->
  <file>./src/</file>
  <exclude-pattern type="relative">^/src/Frontend/Forms/*</exclude-pattern>

  <arg name="basepath" value="." />
  <arg name="colors" />
  <arg name="parallel" value="75" />
  <arg name="severity" value="1" />
  <arg name="report" value="full" />
  <arg value="sp" />

  <rule ref="Generic.Commenting.Todo.CommentFound">
    <message>Please review this TODO comment: %s</message>
    <severity>3</severity>
  </rule>

</ruleset>

There is more in the config, but I left it out for readability (full config at the end).

I would expect the following to throw an error like Please review this TODO comment: @todo find out if this maybe is better suited at another location or Please review this TODO comment: find out if this maybe is better suited at another location. But it throws only Please review this TODO comment: . It's notable in VSCode and on the CLI that two spaces are there at the end, as if %s is returning empty at that point.

Code sample

/**
 * @todo find out if this maybe is better suited at another location
 */
somefunction();

This happens with ANY @todo comment comment.

Versions (please complete the following information):

  • OS: Ubuntu 22.10
  • PHP: 8.1
  • PHPCS: PHP_CodeSniffer version 3.7.2 (stable) by Squiz (http://www.squiz.net)
  • Installed via composer
  • Standard: PSR12

Complete config:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Booka" namespace="Booka">
  <!-- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset -->
  <file>./src/</file>
  <exclude-pattern type="relative">^/src/Frontend/Forms/*</exclude-pattern>

  <arg name="basepath" value="." />
  <arg name="colors" />
  <arg name="parallel" value="75" />
  <arg name="severity" value="1" />
  <arg name="report" value="full" />
  <arg value="sp" />

  <rule ref="Generic.WhiteSpace.ScopeIndent">
    <properties>
      <property name="indent" value="2" />
      <property name="tabIndent" value="false" />
    </properties>
  </rule>
  <rule ref="Generic.WhiteSpace.DisallowTabIndent" />

  <rule ref="Generic.Commenting.Todo.CommentFound">
    <message>Please review this TODO comment: %s</message>
    <severity>3</severity>
  </rule>

  <rule ref="PSR2.Methods.FunctionCallSignature">
    <properties>
      <property name="indent" value="2" />
      <property name="allowMultipleArguments" value="false" />
    </properties>
  </rule>

  <rule ref="PSR12" />
  <rule ref="Modernize" />
  <rule ref="NormalizedArrays" />
  <rule ref="Universal.Arrays.DuplicateArrayKey" />
  <rule ref="Universal.Arrays.MixedArrayKeyTypes" />
  <rule ref="Universal.Arrays.MixedKeyedUnkeyedArray" />
  <rule ref="Universal.Classes.DisallowAnonClassParentheses" />

</ruleset>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions