Rule says, that %n should be used in place of \n to produce the platform-specific line separator, which i agree with. But when I write my LaTeX generating code with \newpage or \newcommand I receive false-positives.
Issue persist in SonarQube Community Edition v9.9.6 (build 92038), and SonarLint (IDEA) 10.7.0.78874
Expected to treat \\ as an exception in regexp searching \n. Possible solution using regex is (?<!\\)\\n instead of \\n while searching for new line placeholders.
Hello, Angelo! I guess it’s not just LaTeX, but any strings that contain escaped backslash followed by n. Not sure if there any other cases where one should replace “backslash-and-a-letter” with “percent-sign-and-a-letter”.
Hello @ivan-igorevich, the current implementation is handling the special case \\n, feel free to check the code. In general it is correct to report this cases unless the string obeys to special syntactic rules like in this case for LaTeX.
Whoever implements the ticket will find the most appropriate solution, which could be to remove this check if it generates too much noise; eventually, there may be a way to infer that the string belongs to LaTeX or other formats that have the \\n as part of keywords in their syntax.
i saw the implementation, that’s why i assumed possible solution. anyhow i can do merge request that implements my solution, and so we discuss it there. Where can i find developers MR guidelines?
Please check the instructions in the Contributing section; all that is required is to create a PR and make sure that the code style is respected and there are tests covering the new code.
Thanks for the contribution. We have scheduled to have a look at some Java-analyzer related issues, this one included, in the coming weeks. We will come back with updates on the Jira ticket linked to by @angelo.buono above, and/or your PR, as applicable.