Skip to content

configurationPropertiesPrefixKebabCase: false positive when prefix uses a const val template #3

@yluom

Description

@yluom

Summary

The configurationPropertiesPrefixKebabCase rule validates the raw string literal passed to @ConfigurationProperties without resolving Kotlin const val references. Prefixes built with string templates referencing top-level constants are flagged even though the runtime value is valid kebab-case.

Reproducer

const val APP_CONFIG_ROOT = "myapp"

@ConfigurationProperties("\$APP_CONFIG_ROOT.foo")
data class FooProperties(val bar: String)

Running springBootRules { all() }.verify() reports:

CodeGuard:configurationPropertiesPrefixKebabCase: @ConfigurationProperties prefix should use lowercase kebab-case segments:
FooProperties has prefix '\$APP_CONFIG_ROOT.foo'

The effective prefix at runtime is myapp.foo, which is valid kebab-case.

Environment

  • spring-boot-code-guard 1.0.7
  • Kotlin 2.3
  • Konsist 0.17.3

Expected

Either:

  1. Resolve the const val reference before validating, or
  2. Skip validation when the prefix contains an unresolved template expression (avoid false positives), or
  3. Document the limitation explicitly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions