diff --git a/src/main/resources/org/eolang/lints/misc/sprintf-constant-args.xsl b/src/main/resources/org/eolang/lints/misc/sprintf-constant-args.xsl new file mode 100644 index 000000000..2b7ec10cb --- /dev/null +++ b/src/main/resources/org/eolang/lints/misc/sprintf-constant-args.xsl @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + warning + + The \"Φ.txt.sprintf\" object uses formatters (\"%s\", \"%d\", etc.) but all arguments are constant strings – consider using a literal string instead of \" + + \" + + + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/sprintf-constant-args/catches-constant-args.yaml b/src/test/resources/org/eolang/lints/packs/single/sprintf-constant-args/catches-constant-args.yaml new file mode 100644 index 000000000..390b13358 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/sprintf-constant-args/catches-constant-args.yaml @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/misc/sprintf-constant-args.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[1][normalize-space()='The \"Φ.txt.sprintf\" object uses formatters (\"%s\", \"%d\", etc.) but all arguments are constant strings – consider using a literal string instead of \"%s ⌒%s\"'] +document: | + + + + + + + 25-73-20-25-73 + + + + + 68-65-6C-6C-6F + + + + + 77-6F-72-6C-64-21 + + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/sprintf-constant-args/passes-non-constant-arg.yaml b/src/test/resources/org/eolang/lints/packs/single/sprintf-constant-args/passes-non-constant-arg.yaml new file mode 100644 index 000000000..ce4b0bd34 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/sprintf-constant-args/passes-non-constant-arg.yaml @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/misc/sprintf-constant-args.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +document: | + + + + + + + 25-73-20-25-73 + + + + + + 68-65-6C-6C-6F + + + + + + 77-6F-72-6C-64-21 + + + + + +