如何防止Spotless/Eclipse加入线路?

Mic*_*fel 7 java eclipse spotless

我有一个项目,使用Spotless 和 Eclipse 格式化程序来检查和格式化源代码。

\n

现在的一个问题是格式化程序创建了一些荒谬的长行,​​如下所示:

\n
    @ApiModelProperty(value = "This is a placeholder text but the real text is just as long as this.", required = true, example = "811769e0-69f8-11e6-91aa-02000ab20f88")\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x80\x99s 170 个字符,我眼睛疲劳,SonarQube 抱怨。当我打破线时,Spotless/Eclipse 坚持将线连接在一起。配置文件包含以下行:

\n
    @ApiModelProperty(value = "This is a placeholder text but the real text is just as long as this.", required = true, example = "811769e0-69f8-11e6-91aa-02000ab20f88")\n
Run Code Online (Sandbox Code Playgroud)\n

文件被很好地拾取,但格式化程序仍然连接这些换行,并且永远不会拆分它们。Eclipse bug 跟踪器中似乎有一个相关的古老(且已关闭)问题 338916 。这可能不是 Spotless 配置问题,因为它将所有内容委托给 Ecplipse 插件。哪个神奇的配置键将说服 Eclipse 格式化程序按照广告中的方式运行?

\n

dev*_*ock 1

我使用了类似的一尘不染的 Eclipse 格式化程序设置,但仍然遇到了同样的问题,格式化程序将包装的 API 文档行连接到单个长行中。我最终做的是启用切换注释并将它们放在我不想加入的行周围。被切换注释包围的换行保持换行。示例如下:

    // spotless:off
    @Operation(summary = "getImagePullCount",
               description = "Generates the docker pulls badge",
               responses = @ApiResponse(description = "An XML representing the SVG docker pulls badge",
                                        content = @Content(mediaType = CONTENT_TYPE_BADGE,
                                        schema = @Schema(implementation = String.class))))
    public String getImagePullCount(@Parameter(in = ParameterIn.QUERY,
                                               description = ApiSpecConstants.API_DESC_PARAM_PACKAGE,
                                               example = ApiSpecConstants.EXAMPLE_PARAM_PACKAGE)
                                    @QueryValue("package") String packageName,
                                    @Parameter(in = ParameterIn.QUERY,
                                               description = ApiSpecConstants.API_DESC_PARAM_LABEL)
                                    @QueryValue(value = "label", defaultValue = "docker pulls") String badgeLabel) {
    // spotless:on
Run Code Online (Sandbox Code Playgroud)