这可能是一个简单的问题:我如何大规模重构我的Java代码,使大多数方法参数成为"最终"?这是遵循我们的"checkstyle"规则之一.我们有数千个Java文件,因此手动编辑所有这些文件对我们来说似乎不是一个可接受的解决方案.
我没有在IntelliJ中找到任何这样的重构选项.有人知道任何有用的工具吗?或者任何实现这一目标的聪明方法?
在我工作的地方,我们主要使用Java.我们一直广泛使用CheckStyle来强制执行Java编码标准.
我们现在正在扩展到Scala.许多与Java相同的注意事项(缩进/空格,命名约定......) - 并且可以说具有一致的编码风格,考虑到语言的强大功能,这一点更为重要.
但是,Scala似乎没有Checkstyle的等效项.
有谁知道吗?
我试图在Rational Software Architect 7.0.0.4上使用eclipse-cs插件.
我最近卸载了较旧的beta2版本并安装了beta3.插件本身的工作方式与之前配置的相同.但每当我尝试通过Windows-> Preferences-> Checkstyle重新配置检查规则时,我都会收到以下错误:
从插件调用代码时出现问题:"org.eclipse.jface".
当我单击配置按钮并尝试在UI上重新配置特定的选定检查规则时,会发生这种情况.
有没有人曾经遇到过这个问题,如何解决?
完整的错误列表和堆栈跟踪如下所示:
Stack trace:
java.lang.NoSuchMethodError: org/eclipse/swt/widgets/Text.setMessage(Ljava/lang/String;)V
at net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.createAdvancedSection(Unknown Source)
at net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.createDialogArea(Unknown Source)
at org.eclipse.jface.dialogs.TitleAreaDialog.createContents(Unknown Source)
at org.eclipse.jface.window.Window.create(Unknown Source)
at org.eclipse.jface.dialogs.Dialog.create(Unknown Source)
at net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.create(Unknown Source)
at org.eclipse.jface.window.Window.open(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationConfigureDialog$PageController.openModule(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationConfigureDialog$PageController.doubleClick(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer$1.run(Unknown Source)
at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
at org.eclipse.core.runtime.Platform.run(Unknown Source)
at org.eclipse.ui.internal.JFaceUtil$1.run(Unknown Source)
at org.eclipse.jface.util.SafeRunnable.run(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(Unknown Source)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(Unknown Source)
at org.eclipse.jface.util.OpenStrategy.access$0(Unknown Source)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown …Run Code Online (Sandbox Code Playgroud) 我在Eclipse中安装了checkstyle插件.如何在工作区中为特定项目禁用它?
如果这不可行,我想关闭checkstyle.
我们的项目包含几个类,我们有Eclipse生成的equals()和hashCode()方法(右键单击 - >源代码 - >生成hashCode()和equals()).
例:
Run Code Online (Sandbox Code Playgroud)@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final MyTO other = (MyTO) obj; if (num != other.num) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (table == null) { if (other.table != null) return false; } else if (!table.equals(other.table)) return false; return true; }
这些方法适用于我们的应用程序,但遗憾的是没有通过Checkstyle的圈复杂度检查.由于这些方法是自动生成的,因此我们不关心它们的复杂性.我们可以从Checkstyle中抑制整个类,但我们希望能够排除这两种方法. …
我想通过Gradle将Checkstyle的输出作为HTML报告.
我在Checkstyle插件文档中找不到任何内容.
我已将以下内容添加到我的build.gradle文件中.
checkstyleTask {
reports {
html {
destination "build/reports/checkstyle.html"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但这产生了
出了什么问题:评估根项目'MyProject'时出现问题.
无法在根项目"MyProject"上找到参数[build_1vu33nc0ekgtoo19jt e86o8o42 $ _run_closure8 @ 1d8ee20]的方法checkstyleTask().
有没有办法使用Gradle生成Checkstyle HTML报告?
谢谢.
Java Checkstyle插件刚刚更新到6.0版本(java 8支持).看起来像gradle使用旧版本.我如何将gradle checkstyle插件升级到更新版本?
我正在尝试在项目中配置Checkstyle.我已经添加:
apply plugin: 'checkstyle'
checkstyle {
// assign the latest checkstyle version explicitly
// default version is very old, likes 5.9
toolVersion = '8.6'
// checkstyle.xml copy from:
// https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-8.6/src/main/resources/google_checks.xml
// the version should be as same as plugin version
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
task Checkstyle(type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
// empty classpath
classpath = rootProject.files()
}
Run Code Online (Sandbox Code Playgroud)
到我的根gradle文件中allprojects.
但是当我跑步的时候 ./gradlew checkstyle
我明白了:
* What went wrong:
Execution failed for task …Run Code Online (Sandbox Code Playgroud) 我希望找到适合Visual Studio的Checkstyle的东西.我最近开始了一个新的工作,做.NET工作,并意识到这里的编码标准有点缺乏.虽然我还是一个年轻人,远离最有经验的开发人员,但我正试图以身作则,让事情朝着正确的方向发展.
我喜欢在Eclipse中使用Checkstyle并在评论之前检查代码的能力,所以我想用Visual Studio做同样的事情.有人有什么好建议吗?
我有点感兴趣的另一件事是SVN的插件,它不允许签到,直到满足主要的编码标准.我不希望人们在代码审查中检查破坏的代码.
此时的任何建议都会很棒.
checkstyle ×10
java ×5
eclipse ×3
coding-style ×2
gradle ×2
android ×1
build.gradle ×1
c# ×1
equals ×1
hashcode ×1
ibm-rational ×1
refactoring ×1
scala ×1