Bug 123936 - Find files to be formatted with clang-format
Summary: Find files to be formatted with clang-format
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.3.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.5.0
Keywords: difficultyBeginner, easyHack, skillPython, skillScript, topicCleanup
Depends on:
Blocks:
 
Reported: 2019-03-08 07:30 UTC by Samuel Mehrbrodt (CIB)
Modified: 2020-07-22 15:22 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Mehrbrodt (CIB) 2019-03-08 07:30:57 UTC
We use clang-format to have consistent formatting on a number of files already. Although most files are currently blacklisted for formatting by 'solenv/clang-format/blacklist'.

The task is to find files where enabling clang-format would only cause minor reformatting (maybe less than 5% of the lines on a file).

Then this file should be removed from 'solenv/clang-format/blacklist' and be formatted with clang-format.

Ideally a (Python/Shell/...) script will be written which does this check for all files. But manually checking is also ok.

Please submit suitable files one by one to Gerrit to allow individual review.
Comment 1 Raghu Ram 2019-03-08 12:59:54 UTC
Hello, I would like to work on it, can I get some code pointers, as I am new to open source contribution but have a fair amount of interest towards contributing to this project and work on this issue.

should I lear
Comment 2 Raghu Ram 2019-03-08 13:04:29 UTC
should I get familiar with any other languages as I already have knowledge of python which is mentioned in keywords?
Comment 3 Samuel Mehrbrodt (CIB) 2019-03-08 13:52:26 UTC
(In reply to Raghu Ram from comment #1)
> Hello, I would like to work on it, can I get some code pointers, as I am new
> to open source contribution but have a fair amount of interest towards
> contributing to this project and work on this issue.
> 
> should I lear

Hi Raghu, what kind of information do you need? The task is written in comment 0.
Please come to the irc channel #libreoffice-dev if you have general questions.
Comment 4 Anuj Agrawal 2019-03-18 16:37:05 UTC
Hi,
I would like to take up this bug. Can you just tell me from where can I access the solenv/clang-format/blacklist file?
Or do I just have to write a Python script which given a list of files outputs the list which has less than 5% of lines to be reformatted to be clang-formatted?
Comment 5 Samuel Mehrbrodt (CIB) 2019-03-19 06:34:11 UTC
(In reply to Anuj Agrawal from comment #4)
> Hi,
> I would like to take up this bug. Can you just tell me from where can I
> access the solenv/clang-format/blacklist file?
> Or do I just have to write a Python script which given a list of files
> outputs the list which has less than 5% of lines to be reformatted to be
> clang-formatted?

The blacklist file is part of our "core" repo. You need a LibreOffice build setup to do this task.
Please see https://wiki.documentfoundation.org/Development/GetInvolved and ask further questions about the setup on IRC.
Comment 6 Samuel Mehrbrodt (CIB) 2019-03-19 07:01:21 UTC
@Anuj: Raghu is currently working on this bug, so please choose another one.
Comment 7 Samuel Mehrbrodt (CIB) 2019-05-23 12:43:28 UTC
As the patch has not seen any progress since 2 months, I mark this issue as unassigned.

Anyone can continue the work started here: https://gerrit.libreoffice.org/#/c/69589/
Comment 8 Stephan Bergmann 2019-12-17 13:25:47 UTC
But note that unconditional application of clang-format will, in general, break the meaning of comments.  Consider code like

  LooooooongType1 looooooongVarName1;
      // lengthy comment about some detail
  LooooooongType2 looooooongVarName2;

where the comment pertains to the preceding line, but needs to go on a new line due to line length limitations, and is indented to make that clear.  It will get reformatted as

  LooooooongType1 looooooongVarName1;
  // lengthy comment about some detail
  LooooooongType2 looooooongVarName2;

making it less obvious whether the comment pertains to the preceding or to the following line.
Comment 9 Commit Notification 2020-01-27 18:10:41 UTC
Batuhan Taskaya committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/09680b09b2f49e7a37d8b941822f053b5179bf6d

tdf#123936: bin/find-clang-format.py for finding files to be formatted

It will be available in 6.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2020-01-28 13:38:22 UTC
Batuhan Taskaya committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/958c35bf761cfc05dfd9a2557ed30d5b1457c3ba

tdf#123936: remove non-existent files from blacklist

It will be available in 6.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Xisco Faulí 2020-07-22 15:22:17 UTC
Dear Batuhan Taskaya,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assign it back to yourself if you're still working on this.