question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot compile unless code is first committed.

See original GitHub issue

On our project, we just added the plugin and formatted our entire codebase (which worked great, BTW).

But when I try to compile our project I’m now getting the following error:

[ERROR] Failed to execute goal com.cosium.code:maven-git-code-format:1.36:validate-code-format (validate-code-format) on project ktc-services: /Users/mcpierce/Repositories/know-the-costs/ktc-services/src/main/java/com/outpatientservicesllc/persistence/service/WorkQueueService.java is not correctly formatted ! -> [Help 1]

Even though our entire codebase was formatted by the plugin. If I git commit the code, without changing it, the build runs fine.

I should also add that I’m using the google-java-format plugin for IntellJ to format code as I go, so the code being saved as pre-formatted correctly.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mcpiercecommented, Nov 21, 2019

@reda-alaoui Okay, understood. We’ll adjust our system to use a profile for CI that runs the check at build time. Thank you!

0reactions
reda-alaouicommented, Nov 21, 2019

I think I understand more clearly your issue.

I bet you are using mvn install to perform your build. install triggers the verify phase.

By default, validate-code-format is bound to maven verify phase. The purpose of validate-code-format is to make the CI fail the build if it find badly formatted files in the git repo. Badly formatted files could be committed/pushed because of a developer that commit without ever running maven (i.e. no installed hooks) or a ‘malicious’ developer that manually removed the hook. The CI is then the last defense against this.

Disabling validate-code-format will only remove this guard. The pre-commit formatting will keep working without any issue.

If you want to keep validate-code-format for the CI while being able to run mvn install locally despite badly formatted files, you have to move it into a maven profile that would be enabled by your CI only.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it acceptable to commit code that doesn't compile?
I think this would largely depend on whether you're working alone or with a team, and if the team agrees if this is...
Read more >
Git Compile Error [duplicate] - Stack Overflow
You have a so-called conflict (file in the working copy and file in the repository have been edited independently from each other, and...
Read more >
How to Fix and Compile Errors
If you can't figure the error out, try commenting out the code you have most recently written until it goes away. Then, reintroduce...
Read more >
5 Debugging Tips for a Solution that Won't Compile
One of the first things a developer is asked to do when starting on a new project is to download the code and...
Read more >
Fix the top 10 most common compile time errors in Java
If code doesn't compile, the program is entirely unable to execute. As such, it's imperative to fix compile time errors in Java as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found