odessajavaclub / coffee-pot

A simple java application to practice with new technologies and for fun
https://odessajavaclub.github.io/
The Unlicense
1 stars 0 forks source link

ISSUE-30 Add google code formatter #31

Closed apletnev closed 4 years ago

apletnev commented 4 years ago

Resolves #30

Description

Testing Details

codecov[bot] commented 4 years ago

Codecov Report

Merging #31 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #31   +/-   ##
=========================================
  Coverage     63.88%   63.88%           
  Complexity        7        7           
=========================================
  Files             7        7           
  Lines            36       36           
  Branches          1        1           
=========================================
  Hits             23       23           
  Misses           13       13
msashkin commented 4 years ago

@apletnev why do we need this formatter as a lib dependency? Shouldn't we include a plugin instead to run it during maven phases?

            <plugin>
                <groupId>com.coveo</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>2.9</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Or am I missing something?

apletnev commented 4 years ago

@msashkin There are few solutions. First, you add a plugin into your IDE, and it formats the code. Second, if you don't use the plugin, a build system must notify you of incorrect styles. Unfortunately, I added the incorrect plugin, that plugin can automatically replace incorrect code with correct one, but it doesn't notify us that the code style is wrong.

msashkin commented 4 years ago

@apletnev my point is that you added this formatter as a library dependency, not a plugin one. Thus, the only way you can use it is by calling its methods directly from the Java code, i.e:

String formattedSource = new Formatter().formatSource(sourceString);

There is no point for us to do that, because we do not generate code.

Instead of this, in my opinion, we should add a plugin dependency, i.e. https://github.com/coveooss/fmt-maven-plugin + Idea plugin