寻找Java代码美化器(或者可能不是美化,而是让代码更优雅的东西)

发布于 2024-09-16 01:33:46 字数 1539 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

晚雾 2024-09-23 01:33:46

您可能想了解一下 Netbeans。它提供代码提示,指出常见做法和错误。

You might want to have a look into Netbeans. It provides code hints, which point out common practices and mistakes.

メ斷腸人バ 2024-09-23 01:33:46

除了 IDE 提供的自动格式化和样式检查之外,您可能对静态代码分析工具< /a> 就像Crap4J,或者来自这个Java 的 SCA 工具列表。它们帮助您提高代码的可读性,并在您使用容易出错的结构时向您发出警告。大多数工具都有 IDE 插件,可让您在编写代码时发现错误的代码。

Except for the auto-formatting and style checking your IDE provides, you may be interested in a static code analysis tool like Crap4J, or something from this list of SCA tools for Java. They help you improve the readability of your code, and warn you when you use error-prone constructs. There are IDE plugins for most tools to let you find bad code as you write it.

凤舞天涯 2024-09-23 01:33:46

您可以使用像 emmaecl 这样的工具,它与 Eclipse 很好地集成。

您还可以使用 Sonar 之类的工具,它对您的源进行质量分析,并提供有关如何进行分析的指标和提示。改进代码。 Sonar 是您安装的 Web 服务。它可以与 Hudson 等自动化构建工具很好地集成,但这不是必需的。

You could use a tool like emmaecl, which integrates nicely with Eclipse.

You could also use something like Sonar which does quality analysis on your sources and provides metrics and hints on how to improve the code. Sonar is a web service you install. It would integrate nicely with an automated build tool like Hudson, but that's not required.

吃不饱 2024-09-23 01:33:46

看看 FindBugsPMD 用于提高 Java 源代码的质量。

看看这篇文章来美化你的Java源代码。

Have a look at FindBugs and PMD for improving the quality of your Java source codes.

Have a look at this post for beautifying your Java source codes.

情深缘浅 2024-09-23 01:33:46

您似乎正在寻找一种工具,它不仅可以帮助您改进代码的视觉外观和一致性(这就是美化器的作用),而且可以帮助您改进其更高级别的结构。 FindBugs 是你的朋友。除了定位代码中的真正错误之外,它还将识别 80 多种不良编码实践和 60 多种狡猾的构造(请参阅

You seem to be looking for a tool that will help you improve not your code's visual appearance and consistency (this is what a beautifier does), but its higher-level structure. FindBugs is your friend. Besides locating real bugs in your code, it will also identify more than 80 bad coding practices and more than 60 dodgy constructs (see this list).

浪荡不羁 2024-09-23 01:33:46

您可以使用 艺术风格(适用于 C、C++、C# 和 Java),它有很多选项,因此您可以您喜欢的设置风格。

您可以从命令行使用它,或者如果您仔细观察,您可能会找到主流 IDE 的插件(据我所知,它集成在 KDevelop 中,并且有 Qt Creator 的插件)。

You can use Artistic Style (works for C, C++, C# and Java) which has many options so you can set-up style you like.

You can use it either from command line or if you look hard you might find plugins for the mainstream IDEs (For what I know, it's integrated in KDevelop and there is plugin for Qt Creator).

爱要勇敢去追 2024-09-23 01:33:46

大多数 IDE 都具有格式化功能。 Eclipse 是一个免费的开源 IDE,可以格式化 Java 源文件

Most IDEs will have formatting capability. Eclipse, which is a free, OpenSource IDE, will format Java soruce files

倥絔 2024-09-23 01:33:46

Eclipse 可以格式化您的代码。
您可以在这里自定义它:Window/Preferences/Java/Code Style

Maybe 静态代码分析工具 就像 FindbugsPMD 可能会让您感兴趣。

Eclipse can format your code.
You can customize it here: Window/Preferences/Java/Code Style

Maybe static code analysis tools like Findbugs or PMD could interesst you.

秋叶绚丽 2024-09-23 01:33:46

Eclipse 具有代码“清理”功能。您可以在下面找到它

窗口 ->首选项-> Java->代码风格 - 清理。

这样做的好处是您可以在 SVN 中的项目中检查此首选项。这样,如果您有多个人在一个项目上进行协作,您只需定义代码清理选项,也许还有格式化程序选项。这对于不必在编码指南中定义所有内容大有帮助(它们仍然是必要的,但是您现在可以通过这些选项定义很多内容)。

Eclipse has a code "Clean Up" functionality. You can find it under

Window -> Preferences -> Java -> Code Style - Clean Up.

The nice thing about this is that you can check this preferences in with your project in SVN. This way if you have multiple people collaborating on a project you just define your code Clean Up options and maybe your Formatter options. This goes a long way to not having to define everything in coding guidelines (they are still necessary, but there's a lot of stuff you can now define via those options).

澜川若宁 2024-09-23 01:33:46

您可能还想探索 Checkstyle

You might also want to explore Checkstyle.

场罚期间 2024-09-23 01:33:46

如果使用 IDE,那么至少 Netbeans 和 Eclipse 都具有清理和重新格式化代码的功能。

Netbeans 允许您将代码格式配置为非常详细的级别,即是否在花括号之前包含换行符。打破长行等设置/首选项->编辑器->格式。

配置后,您只需在打开的文件上使用 ctrl+shift+f (cmd+shift+f),所有垃圾都会自动清理。

我非常确定 Eclipse 也可以使用同样的功能。还没有深入研究配置部分,但至少可以进行格式化,并且可以非常整齐地重新格式化和清理代码。

例如,来自商业独立工具 jindent 的技巧 http://www.jindent.com/

If using the IDE, then at least Netbeans and Eclipse both have functionality to clean up and reformat code.

Netbeans allows you to configure the code formatting to quite detailed level, i.e. including line break before the curly braces or not. Breaking long lines etc. Settings/Preferences->Editor->Formatting.

After configuration you just use ctrl+shift+f (cmd+shift+f) on your open file and all the crap gets automagically cleaned up.

I'm pretty certain the same thing is available for Eclipse also. Haven't dug into the configuration part, but formatting at least was available and was reformatting and cleaning up the code pretty neatly.

From commercial standalone tools jindent does the trick http://www.jindent.com/ for example.

倚栏听风 2024-09-23 01:33:46

如果我是你,我会看看 Sonar (http://sonarsource.org),它使用了上述许多内容工具,例如 PMD、Checkstyle 和 Findbugs,让您直观地了解代码质量。

I'd look at Sonar if I were you (http://sonarsource.org), it uses many of the aforementioned tools, such as PMD, Checkstyle and Findbugs and gives you an intuitive overview of the quality of your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文