简体   繁体   English

修复 IntelliJ IDEA 中不必要的 GString 违规

[英]Fix UnnecessaryGString violations in IntelliJ IDEA

When I analyzed my project using CodeNarc I get huge number of UnnecessaryGString violations.当我使用 CodeNarc 分析我的项目时,我得到了大量的UnnecessaryGString违规。

I can fix them one by one by pressing ALT + ENTER and choosing Convert to String option.我可以通过按ALT + ENTER并选择Convert to String选项来一一修复它们。 This is very tedious process though.虽然这是一个非常乏味的过程。

Is there any autofix in IntelliJ to replace all unncessary GStrings with Strings? IntelliJ 中是否有任何自动修复可以用字符串替换所有不必要的 GString? If not, what do I need to do to create my own?如果没有,我需要做什么来创建自己的?

Currently I use error prone replacement from "([^$\n"]+)"(?!\() to '$1' . It gives some false positives on more complex cases (eg with escaping).目前我使用容易出错的替换从"([^$\n"]+)"(?!\()'$1' 。它在更复杂的情况下给出了一些误报(例如转义)。

You can try use this tool and run it with --fix :您可以尝试使用此工具并使用--fix运行它:

https://github.com/nvuillam/npm-groovy-lint https://github.com/nvuillam/npm-groovy-lint

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM