FHIR module build Issue with respect to formatting.

Whenever I try to build the fhir2 module it formats all the files even though on checking there are no changes inside the files in git. I have even checked the line-endings for my windows machine git config --global core.autocrlf is set to true.

I think I have the correct formatting settings i.e the OpenMRSFormatter.xml file since the openmrs-core repo works fine for me.

Here is the build log cc @gcliff @ibacher .

@saurabh this looks more of an issue of the settings with your IDE

Not happening with other openmrs-repositories though :frowning:

This isn’t an error, but is the expected behaviour. Early on in working on the FHIR2 module, I added some automated code formatting to ensure that code committed by all our contributors is in a consistent format. Most OpenMRS repos just aren’t setup with a code formatting step because it’s quite difficult to apply code formatting to something after the fact.

@ibacher but after these files are formatted there is no change in the git history it just shows that files have been modified, and In addition I just re cloned the repo and its still happening without even making any change. is it expected?

Yes… the formatter still attempts to apply updated formatting to all the files. If no changes are necessary, this is a relatively fast operation.

1 Like

I am still a bit confused here, since the formatter formats all the files during a build so all the files on the github repo must already be inline with the formatting. so why is the formatting step modifying the files even when I havent made any change to the files.

The formatter doesn’t have any knowledge of Git, so it doesn’t really have any concept of “has this file been modified”. It just scans the source files in the repository, which is all it’s reporting doing.

Actually earlier it used to skip those files which I did not modify, so it used to say 460 files skipped, but after pulling in recent changes all the files in the master branch all files get modified and its difficult to make a commit since it includes all those files as well which get modified by the formatter ( to say atlease since the git diff shows just that files have been modified but there are no changes in the files)

cc @theanandankit also faced similar Issue after pulling in recent changes but he faced it for smaller number of files.

It may be that the line-endings are being changed, but Git is ignoring those changes? E.g., the files in the repo should have Unix-style new lines, but when you check them out using autocrlf, Git will convert them to Windows-style new lines then the formatter changes them back, but Git doesn’t see this as an actual difference? That’s just a guess.

2 Likes

Yes, thats what I thought thats why I checked the line endings first, I will check again Thanks !

I’m not sure but I think I’m facing this issue because of the previous commits. After running mvn clean install the formatter cleans up the code but only for 5 files.

It looks like there were some updates needed that I’ve pushed. @saurabh can you try updating to the latest master and see if this is fixed for you?

2 Likes

Its back to normal now not modifying the files anymore :grinning:

1 Like