alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
29.94k stars 12.78k forks source link

Use spotless plugin to format the code to ensure that the format of the submitted code is uniform #11021

Open liugddx opened 1 year ago

liugddx commented 1 year ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

liugddx commented 1 year ago

@KomachiSion Can we format code with spotless?

KomachiSion commented 1 year ago

No, maven plugin reformat code will cause many invalid the commits in PR. We prefer use codeStyle to do it when developer developing.

liugddx commented 1 year ago

No, maven plugin reformat code will cause many invalid the commits in PR. We prefer use codeStyle to do it when developer developing.

emm.. you're right. This is a case used by apache shardingsphere, maybe can refer to avoid invalid code changes

https://medium.com/codex/how-does-apache-shardingsphere-standardize-and-format-code-we-use-spotless-caf09403de6a

KomachiSion commented 1 year ago

Whether the link is right? I can't open it even i use vpn.

If use maven plugin, whether the two problem solved?

  1. developers do mvn build command in local and just do the commit in PR, it will has one invalid commit about the code reformat. It can't avoid the review in code when developer not do mvn build command.
  2. if in work flow add the check for reformat plugin, it will cause the ci flow has some modifies need to commit.

I know the sofa use this way to auto check the reformat way, But We prefer developer can use codeStyle to do reformat during developing.

Of cource, if the two problem can be solved well, we also welcome use plugin to auto reformat.

liugddx commented 1 year ago

Thank you for your reply. Both points you mentioned can be satisfied.I can submit a pr to fix it.

liugddx commented 12 months ago

https://nightlies.apache.org/flink/flink-docs-stable/docs/flinkdev/ide_setup/#intellij-idea

This is the formatting of the code of Apache Flink.We can refer to it.

KomachiSion commented 11 months ago

The document in nacos also included, both document and source codes.

From your PR, I can't get the key point. Did you means that the spotless plugin conflict codestyle plugin?

liugddx commented 11 months ago

The document in nacos also included, both document and source codes.

From your PR, I can't get the key point. Did you means that the spotless plugin conflict codestyle plugin?

Yes, when I run mvn spotless:apply, the code will be formatted and checkstyle will verify that these changes do not comply with. This is caused by the inconsistent rules of the two plug-ins.

KomachiSion commented 11 months ago

so should we use double maven commands? for example: first run spotless without checkstyle and then run check command in action.

liugddx commented 11 months ago

https://github.com/apache/doris/pull/25033

My pr in apache doris, but I removed the checkstyle check. I can't resolve the conflict between these two plugins, therefore, I chose to use spotless to cover the checkstyle rules as much as possible.

KomachiSion commented 10 months ago

So use checkstyle to keep running first. If spotless can replace checkstyle fully, then use spotless replace it.

miclosgyjf commented 2 months ago

¿Su solicitud de función está relacionada con un problema? Por favor describa. Una descripción clara y concisa de cuál es el problema. Ex. Siempre me siento frustrado cuando [...]

Describe la solución que te gustaría. Una descripción clara y concisa de lo que quieres que suceda.

Describa las alternativas que haya considerado. Una descripción clara y concisa de cualquier solución o característica alternativa que haya considerado.

Contexto adicional Agregue aquí cualquier otro contexto o captura de pantalla sobre la solicitud de función.

https://github.com/alibaba/nacos/issues/11021#issue-1866759696