spotless格式化插件

目的:

      便于阅读、便于协作

特性:
  • 检查代码格式,自动统一风格;
  • 根据规则自动修改不复合规范的代码格式;
  • 开发过程中引入该插件时,可以只对最新提交的源文件进行格式检查和修改,不影响已提交的源文件
  • 支持多种语言;
官方文档:

https://github.com/diffplug/spotless/blob/main/plugin-maven/README.md

使用:
<plugin>
  <groupId>com.diffplug.spotless</groupId>
  <artifactId>spotless-maven-plugin</artifactId>
  <version>${spotless.version}</version>
  <configuration>
    <!-- optional: limit format enforcement to just the files changed by this feature branch -->
    <ratchetFrom>origin/main</ratchetFrom>
    <formats>
      <!-- you can define as many formats as you want, each is independent -->
      <format>
        <!-- define the files to apply to -->
        <includes>          
            <include>src/**/java/**/*.java</include>
      </includes>
        <!-- define the steps to apply to those files -->
        <trimTrailingWhitespace/>
        <endWithNewline/>
        <indent>
          <tabs>true</tabs>
          <spacesPerTab>4</spacesPerTab>
        </indent>
      </format>
    </formats>
    <!-- define a language-specific format -->
    <java>
      <!-- no need to specify files, inferred automatically, but you can if you want -->
 
      <!-- apply a specific flavor of google-java-format and reflow long strings -->
      <googleJavaFormat>
        <version>1.8</version>
        <style>AOSP</style>
        <reflowLongStrings>true</reflowLongStrings>
      </googleJavaFormat>
 
      <!-- make sure every file has the following copyright header.
        optionally, Spotless can set copyright years by digging
        through git history (see "license" section below) -->
      <licenseHeader>
        <content>/* (C)$YEAR */</content>  <!-- or <file>${project.basedir}/license-header</file> -->
      </licenseHeader>
  </java>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
org.jacoco是一个用于Java代码覆盖率测试和报告生成的开源工具。它可以帮助开发人员分析他们的代码测试覆盖率情况,并生成详细的报告。在你提供的引用中,主要是关于二次开发的一些修改和使用方法。 根据第一个引用,jacoco二次开发主要加入了增量代码匹配的功能。具体的设计方案可以参考jacoco的增量代码实践。这个二次开发主要是新增了一些类和修改了一些核心类。新增的类位于org.jacoco.core.internal.diff包下,而修改的类主要包括org.jacoco.core.analysis.Analyzer、org.jacoco.core.analysis.CoverageBuilder和org.jacoco.core.internal.flow.ClassProbesAdapter。你可以通过查看commit记录来了解具体的修改内容。 关于使用方法,首先需要下载源码,并运行mvn spotless:apply命令。这个命令主要是用于进行文件头文件校验,如果新增加了类或者修改了类,需要重新校验。然后,运行mvn clean package -Dmaven.test.skip=true -Dmaven.javadoc.skip=true命令进行构建。构建完成后,你可以在target目录下找到org.jacoco.cli-0.8.7-SNAPSHOT-nodeps.jar,这是构建出的需要的包。 关于生成单元覆盖率报告,你可以运行maven test命令。然后,在target目录下会生成jacoco-ut文件夹,其中包含了index.html文件,你可以用浏览器打开这个文件来查看单元覆盖率报告。 至于你提到的最开始未找到单元测试报告的问题,可能是因为在pom.xml配置中没有加入report部分的依赖,并指定report的位置。请确保你的pom.xml文件中有正确的配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风卷残尘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值