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

Automated Standards Checking #3265

Merged
merged 4 commits into from
Feb 21, 2019

Conversation

dorodnic
Copy link
Contributor

Somewhat necessary evil - this will enforce during CI the following requirements on every future PR:

  1. Every example / source file must refer to LICENSE
  2. Every example / source file must include correct copyright notice
  3. For indentation we are using spaces and not tabs
  4. Line-endings must be Unix and not DOS style
  5. Every API header file must be able to compile as the first included header (no implicit dependencies)

Also updating all affected files to allow this to pass CI.

fi

cd ..
check_folder include $1
Copy link
Contributor

Choose a reason for hiding this comment

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

@dorodnic What about the wrappers folder? It contains files that are not updated (i.e python)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first, I did. In particular nodejs and python are obvious candidates.
However, both wrappers contain 3rd-party code within them that needs to be ignored.
While we should extend to wrappers as well, I'm ok to have only the core library covered for now.

if [[ $(git check-ignore $filename | wc -l) -eq 0 ]]; then
if [[ $(grep -oP "(?<=\(c\) )(.*)(?= Intel)" $filename | wc -l) -eq 0 ]]; then
echo "[ERROR] $filename is missing the copyright notice"
ok=$((ok+1))
Copy link
Contributor

Choose a reason for hiding this comment

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

@dorodnic why not $ok = 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to count the number of errors to print it in the end.
This helps the user, as he can see this number get lower as he works through the issues.

ok=$((ok+1))

if [[ $2 == *"fix"* ]]; then
if [[ $(date +%Y) == "2019" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

@dorodnic I am sure that we will forget to update when we get to 2020 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mostly due to my lack of bash knowledge. I'm using ex -sc '1i|// Copyright(c) 2019 Intel Corporation to append copyright before the first line.
However, if you try to use variables in that line (ex -sc '1i|// Copyright(c) $(date +%Y) Intel Corporation) you will just see "// Copyright(c) $(date +%Y) Intel Corporation" appended to the file. I tried to figure this out for half-an-hour and eventually gave up.
If someone knows how to do this better, will be happy to change it.

./pr_check.sh
else
if [[ ${ok} -ne 0 ]]; then
echo Pull-Request check failed, please address ${ok} the errors reported above
Copy link
Collaborator

Choose a reason for hiding this comment

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

the errors

@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
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 this (link) the year marks when the work was first published.
It is not really a rule, more a convention to keep the original date. But re-tagging the files, imho will produce extra-burden both for PR submitters and reviewers.

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you also add a check that a source file will always end with an empty line (like this one) ?

@@ -66,7 +66,7 @@ int uvc_get_ctrl_len(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl) {
devh->usb_devh,
REQ_TYPE_GET, UVC_GET_LEN,
ctrl << 8,
unit << 8 | devh->info->ctrl_if.bInterfaceNumber, // XXX saki
unit << 8 | devh->info->ctrl_if.bInterfaceNumber, // XXX saki
Copy link
Collaborator

@ev-mp ev-mp Feb 18, 2019

Choose a reason for hiding this comment

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

The libuvc should probably be excluded, at least temporally. So then if we get a fix from a 3rd party to libuvc library, it will be much easier to compare and merge.
Actually, if we're going to make fixes into libuvc the script will automatically require us to add Intel's copyright as this is under /src

target_sources(${LRS_TARGET}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/cuda-align.h"
"${CMAKE_CURRENT_LIST_DIR}/cuda-align.cu"
"${CMAKE_CURRENT_LIST_DIR}/cuda-align.cuh"
"${CMAKE_CURRENT_LIST_DIR}/cuda-pointcloud.h"
"${CMAKE_CURRENT_LIST_DIR}/cuda-pointcloud.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indentation mismatch

@dorodnic dorodnic merged commit 03a8c5a into IntelRealSense:development Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants