Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-order includes (fixes #3132) #3133

Merged
merged 1 commit into from
Jun 1, 2020
Merged

Conversation

jameslamb
Copy link
Collaborator

See #3132 for details. The lint task in CI is broken right now because of a new release to cpplint a few hours ago. As of that release, cpplint now enforces the Google style guide recommendations for how includes should be ordered:

  1. dir2/foo2.h.
  2. A blank line
  3. C system headers (more precisely: headers in angle brackets with the .h extension), e.g., <unistd.h>, <stdlib.h>.
  4. A blank line
  5. C++ standard library headers (without file extension), e.g., , .
  6. A blank line
  7. Other libraries' .h files.
  8. Your project's .h files.

And the reason this is recommended:

With the preferred ordering, if the related header dir2/foo2.h omits any necessary includes, the build of dir/foo.cc or dir/foo_test.cc will break. Thus, this rule ensures that build breaks show up first for the people working on these files, not for innocent people in other packages.

#include <fstream>
#include <sstream>
#include <utility>

#include <LightGBM/application.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the Google style, LightGBM/application.h (the same issue with the most cpp files from this PR) should be the first one. Is there a bug in cpplint which blocks us from using the correct order? Refer to #2066 (comment).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thanks, I didn't know about #2066!

Yes, if I move just LightGBM/application.h back to the top and leave everything else the same in this PR, I get this from cpplint

src/application/application.cpp:8: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]
src/application/application.cpp:9: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]
src/application/application.cpp:10: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]
src/application/application.cpp:11: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]
src/application/application.cpp:12: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]
src/application/application.cpp:13: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]
src/application/application.cpp:14: Found C++ system header after other system header. Should be: application.h, c system, c++ system, other. [build/include_order] [4]

I think it is probably because this is called application/application.cpp and cpplint is expecting to find "application.h" (header colocated with implementation). When I change <LightGBM/application.h> to "application.h" (and leave everything else in this PR the same), cpplint does not raise any warnings.

image

If we want to stick to the intent of the style guide, I guess we could make (for example) LightGBM/application.h the first header and just add //NOLINT. That would be closer to what the style guide says, even if cpplint fails to pick it up. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if I move just LightGBM/application.h back to the top and leave everything else the same in this PR, I get this from cpplint

Oh, it's a pity! But thanks, this is exactly what I wanted to know.

What do you think?

I think that adding //NOLINT in each file is very ugly "fix" and makes no sense. Quoting myself from #2066

IMHO, any order is OK in case it's the same across the whole project.

I suggest only document our own new style guide for includes. So that we will be able to use it as a reference for new files in the future. Just like I did it earlier:

But due to the bug only the following order doesn't produce errors:

dir2/foo2.h.
A blank line
Your project's .h files in include folder.
A blank line
C system files.
C++ system files.
A blank line
Other libraries' .h files.
Your project's .h files in src folder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, do you mean I should push a commit adding this new standard somewhere? If so could you suggest where?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no! I mean, just post it here as a comment.

@StrikerRUS StrikerRUS merged commit 656d267 into microsoft:master Jun 1, 2020
StrikerRUS added a commit that referenced this pull request Jun 5, 2020
StrikerRUS added a commit that referenced this pull request Jun 5, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 10, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 10, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 11, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 11, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 11, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 11, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 24, 2020
ChipKerchner pushed a commit to ChipKerchner/LightGBM that referenced this pull request Jun 24, 2020
@jameslamb jameslamb deleted the ci/cpplint branch September 7, 2020 05:26
guolinke added a commit that referenced this pull request Sep 20, 2020
* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* Initial CUDA work

* redirect log to python console (#3090)

* redir log to python console

* fix pylint

* Apply suggestions from code review

* Update basic.py

* Apply suggestions from code review

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>

* Update c_api.h

* Apply suggestions from code review

* Apply suggestions from code review

* super-minor: better wording

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: StrikerRUS <nekit94-12@hotmail.com>

* re-order includes (fixes #3132) (#3133)

* Revert "re-order includes (fixes #3132) (#3133)" (#3153)

This reverts commit 656d267.

* Missing change from previous rebase

* Minor cleanup and removal of development scripts.

* Only set gpu_use_dp on by default for CUDA. Other minor change.

* Fix python lint indentation problem.

* More python lint issues.

* Big lint cleanup - more to come.

* Another large lint cleanup - more to come.

* Even more lint cleanup.

* Minor cleanup so less differences in code.

* Revert is_use_subset changes

* Another rebase from master to fix recent conflicts.

* More lint.

* Simple code cleanup - add & remove blank lines, revert unneccessary format changes, remove added dead code.

* Removed parameters added for CUDA and various bug fix.

* Yet more lint and unneccessary changes.

* Revert another change.

* Removal of unneccessary code.

* temporary appveyor.yml for building and testing

* Remove return value in ReSize

* Removal of unused variables.

* Code cleanup from reviewers suggestions.

* Removal of FIXME comments and unused defines.

* More reviewers comments cleanup.

* More reviewers comments cleanup.

* More reviewers comments cleanup.

* Fix config variables.

* Attempt to fix check-docs failure

* Update Paramster.rst for num_gpu

* Removing test appveyor.yml

* Add �CUDA_RESOLVE_DEVICE_SYMBOLS to libraries to fix linking issue.

* Fixed handling of data elements less than 2K.

* More reviewers comments cleanup.

* Removal of TODO and fix printing of int64_t

* Add cuda change for CI testing and remove cuda from device_type in python.

* Missed one change form previous check-in

* Removal AdditionConfig and fix settings.

* Limit number of GPUs to one for now in CUDA.

* Update Parameters.rst for previous check-in

* Whitespace removal.

* Cleanup unused code.

* Changed uint/ushort/ulong to unsigned int/short/long to help Windows based CUDA compiler work.

* Lint change from previous check-in.

* Changes based on reviewers comments.

* More reviewer comment changes.

* Adding warning for is_sparse. Revert tmp_subset code. Only return FeatureGroupData if not is_multi_val_

* Fix so that CUDA code will compile even if you enable the SCORE_T_USE_DOUBLE define.

* Reviewer comment cleanup.

* Replace warning with Log message. Removal of some of the USE_CUDA. Fix typo and removal of pragma once.

* Remove PRINT debug for CUDA code.

* Allow to use of multiple GPUs for CUDA.

* More multi-GPUs enablement for CUDA.

* More code cleanup based on reviews comments.

* Update docs with latest config changes.

Co-authored-by: Gordon Fossum <fossum@us.ibm.com>
Co-authored-by: ChipKerchner <ckerchne@linux.vnet.ibm.com>
Co-authored-by: Guolin Ke <guolin.ke@outlook.com>
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: StrikerRUS <nekit94-12@hotmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants