{"record":{"id":"88754ed1f310dfb3","repo":"JetBrains/intellij-community","slug":"unnecessary-argument-position-specifier-0-in","errorCode":null,"errorMessage":"unnecessary argument position specifier ''{0}'' in ''{1}''","messagePattern":"unnecessary argument position specifier ''(.+?)'' in ''(.+?)''","errorType":"exception","errorClass":"FormatDecode.IllegalFormatException","httpStatus":null,"severity":"error","filePath":"java/java-analysis-impl/src/com/siyeh/ig/format/FormatDecode.java","lineNumber":279,"sourceCode":"      // check this first because it should not affect \"implicit\"\n      if (\"n\".equals(conversion)) {\n        // no flags allowed\n        checkFlags(flagBits, 0, specifier);\n        if (!StringUtil.isEmpty(width)) {\n          throw new IllegalFormatException(InspectionGadgetsBundle.message(\"format.string.error.width.not.allowed\", width, specifier));\n        }\n        checkNoPrecision(precision, specifier);\n        continue;\n      }\n      else if (\"%\".equals(conversion)) { // literal '%'\n        checkFlags(flagBits, LEFT_JUSTIFY, specifier);\n        checkNoPrecision(precision, specifier);\n        continue;\n      }\n\n      if (posSpec != null) {\n        if (isAllBitsSet(flagBits, PREVIOUS)) {\n          throw new IllegalFormatException(\n            InspectionGadgetsBundle.message(\"format.string.error.unnecessary.position.specifier\", posSpec, specifier));\n        }\n        final String num = posSpec.substring(0, posSpec.length() - 1);\n        pos = Integer.parseInt(num) - 1;\n        if (pos < 0) {\n          throw new IllegalFormatException(\n            InspectionGadgetsBundle.message(\"format.string.error.illegal.position.specifier\", posSpec, specifier));\n        }\n        previousAllowed = true;\n      }\n      else if (isAllBitsSet(flagBits, PREVIOUS)) {\n        // reuse last pos\n        if (!previousAllowed) {\n          throw new IllegalFormatException(InspectionGadgetsBundle.message(\"format.string.error.previous.element.not.found\", specifier));\n        }\n      }\n      else {\n        previousAllowed = true;","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-analysis-impl/src/com/siyeh/ig/format/FormatDecode.java#L261-L297","documentation":"IllegalFormatException from FormatDecode when an explicit argument-position specifier like '2$' is combined with the '<' (previous argument) flag in the same specifier — e.g. '%2$<d'. The two addressings are mutually exclusive: posSpec selects an argument index, '<' reuses the previous one; having both is meaningless, so decode() rejects it.","triggerScenarios":"A specifier containing both an index like 'N$' and a '<' flag, e.g. '%1$<s'; posSpec != null and PREVIOUS bit set.","commonSituations":"Hand-merging format specifiers when reordering arguments; copy-paste mixing relative and indexed styles in one string.","solutions":["Keep exactly one addressing style per specifier: either 'N$' or '<', not both","Prefer one consistent style (all indexed or all relative) across the whole format string"],"exampleFix":"// before\nString.format(\"%1$<s %s\", \"a\", \"b\")\n// after\nString.format(\"%1$s %2$s\", \"a\", \"b\")","handlingStrategy":"validation","validationCode":"static boolean addressingConsistent(String posSpec, boolean hasPreviousFlag) {\n  return !(posSpec != null && hasPreviousFlag); // 'N$' and '<' are mutually exclusive\n}","typeGuard":null,"tryCatchPattern":"try { FormatDecode.decode(fmt, argc); } catch (IllegalFormatException e) { /* remove '<' or the index from the specifier */ }","preventionTips":["Pick one addressing style per format string and stick to it"],"tags":["intellij","format-string","inspection","java","parsing"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}