From 197b7b96c8e852a6b99574af72a909b6cea81eb2 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Fri, 16 Oct 2026 20:32:22 +0800 Subject: [PATCH 1/2] docs: explain local nolint style suppression --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 33ca911c..23e6a6c2 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,25 @@ it's legit to declare a variable that's not used if the goal is to verify that a templatized function can be instantiated by inference of the type of this variable. To avoid these cases, it's possible to pass the "--skipTests" option. +#### Suppressing a check on a declaration + +A declaration can opt out of one or more checks with a `nolint` user-defined +attribute. For example, to keep a C binding's original name without disabling +style checking for the rest of the file: + +```d +extern (C) +{ + @("nolint(dscanner.style.phobos_naming_convention)") + int CRYPTO_memcmp(const(void)* first, const(void)* second, size_t count); +} +``` + +This suppression is supported by builds that include the `nolint` feature (merged +in [#936](https://github.com/dlang-community/D-Scanner/pull/936)); it is not +available in the latest stable release, v0.15.2. It affects D-Scanner's check +for the annotated declaration, unlike editor-specific ignore settings. + #### Configuration By default all checks are enabled. Individual checks can be enabled or disabled by using a configuration file. Such a file can be placed, for example, is the root directory of your project. From 717740f105d0289090f61e7cc2dd003aedbb5508 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Fri, 16 Oct 2026 20:45:33 +0800 Subject: [PATCH 2/2] docs: use verified nolint example and note naming limitation --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 23e6a6c2..e9d8aa06 100644 --- a/README.md +++ b/README.md @@ -201,16 +201,14 @@ To avoid these cases, it's possible to pass the "--skipTests" option. #### Suppressing a check on a declaration -A declaration can opt out of one or more checks with a `nolint` user-defined -attribute. For example, to keep a C binding's original name without disabling -style checking for the rest of the file: +A declaration can opt out of checks that support the `nolint` user-defined +attribute. For example, to suppress a redundant-initializer warning on just one +declaration: ```d -extern (C) -{ - @("nolint(dscanner.style.phobos_naming_convention)") - int CRYPTO_memcmp(const(void)* first, const(void)* second, size_t count); -} +@("nolint(dscanner.useless-initializer)") +int count = 0; +int nearby = 0; // Still checked. ``` This suppression is supported by builds that include the `nolint` feature (merged @@ -218,6 +216,11 @@ in [#936](https://github.com/dlang-community/D-Scanner/pull/936)); it is not available in the latest stable release, v0.15.2. It affects D-Scanner's check for the annotated declaration, unlike editor-specific ignore settings. +Not every check honors declaration-level suppression. In particular, the current +Phobos naming checker still reports C binding names such as `CRYPTO_memcmp` even +with `@("nolint(dscanner.style.phobos_naming_convention)")` on the declaration. +Upgrading from v0.15.2 alone does not resolve that limitation. + #### Configuration By default all checks are enabled. Individual checks can be enabled or disabled by using a configuration file. Such a file can be placed, for example, is the root directory of your project.