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

Refactor and shellcheck cleanup in report_errors.sh and check_style.sh #10797

Merged

Conversation

cameel
Copy link
Member

@cameel cameel commented Jan 15, 2021

NOTE: This PR is based on #10792 and should not be merged before it. It's on develop now.

This is the extra, optional cleanup for the scripts for checking and reporting code style errors. It contains the relevant bits from #10585 and #10586 and a few more things. This is not everything that can be done here but that's the part I managed to finish today and is complete enough to be a PR of its own.

@cameel cameel self-assigned this Jan 15, 2021
)
EXCLUDE_FILES_JOINED=$(printf "%s\|" "${EXCLUDE_FILES[@]}")
EXCLUDE_FILES_JOINED=${EXCLUDE_FILES_JOINED%??}

(
REPO_ROOT="$(dirname "$0")"/..
cd $REPO_ROOT
cd "$REPO_ROOT" || exit 1
Copy link
Member Author

@cameel cameel Jan 15, 2021

Choose a reason for hiding this comment

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

Switching to set -e would be better but I did not have enough time to test the script with it properly today so I decided to go with this for now.

preparedGrep "#include \"" | egrep -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters
preparedGrep "\<(if|for|while|switch)\(" # no space after "if", "for", "while" or "switch"
preparedGrep "\<for\>\s*\([^=]*\>\s:\s.*\)" # no space before range based for-loop
preparedGrep "\<if\>\s*\(.*\)\s*\{\s*$" # "{\n" on same line as "if" / "for"
Copy link
Member Author

Choose a reason for hiding this comment

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

The comment wasn't true so I removed the part about for. But why actually aren't we checking for? Is there any reason this isn't (if|for|while|switch)? I checked blame and it looks like it was if from the beginning.

Copy link
Member

Choose a reason for hiding this comment

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

I personally have no idea why.
@chriseth @axic ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add all of them.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. But in that case I'll do it in a separate PR because this will require fixing the style issues that were passing though this check until now.

echo $ERROR_MSG

if [ ! -z $CI ]
if [[ $CI == "true" ]]
Copy link
Member Author

Choose a reason for hiding this comment

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

Could also be $CI != "" but I see in CircleCI that this is set to true and I think this check is more readable.

@cameel cameel force-pushed the refactor-and-shellcheck-cleanup-in-report-errors-sh branch from 54e3d8f to f68cc14 Compare January 18, 2021 14:27
Base automatically changed from fix-github-api-errors-from-check-style to develop January 19, 2021 12:46
@cameel cameel marked this pull request as draft January 20, 2021 11:20
@cameel cameel force-pushed the refactor-and-shellcheck-cleanup-in-report-errors-sh branch from f68cc14 to 81f3c74 Compare January 20, 2021 12:29
@cameel
Copy link
Member Author

cameel commented Jan 20, 2021

Oh, this one is actually not blocked by anything. Switching back to "ready to review".

@cameel cameel marked this pull request as ready for review January 20, 2021 12:30
Copy link
Member

@leonardoalt leonardoalt left a comment

Choose a reason for hiding this comment

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

lgtm but there's a question I don't have an answer for.

@cameel cameel requested a review from chriseth January 21, 2021 17:06
@cameel
Copy link
Member Author

cameel commented Jan 21, 2021

@leonardoalt We have an answer now. I'll change it but this PR is ready to merge now so I think it's better to merge it and update this rule in a new one.

@leonardoalt leonardoalt merged commit ead1a26 into develop Jan 22, 2021
@leonardoalt leonardoalt deleted the refactor-and-shellcheck-cleanup-in-report-errors-sh branch January 22, 2021 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants