-
Notifications
You must be signed in to change notification settings - Fork 97
feat: CI - Add code rules checking action #3914
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
Open
arng40
wants to merge
91
commits into
develop
Choose a base branch
from
feat/dudes/add-code-rules
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
6f8f1c0
add-code-rules
arng40 243af07
comment jobs not needed
arng40 7754898
try this
arng40 29f0ed6
remove ctest testcoderule
arng40 3d2782a
try to add some target
arng40 38748b0
relaunch ci
arng40 21956b3
forget 1 target
arng40 183262c
test code for detecting std::map
arng40 1a50cc9
force to true
arng40 4004d12
log
arng40 42d6f5b
more log
arng40 6a87699
print pwd
arng40 3ae12c4
test with regex
arng40 06b6d8f
fix
arng40 9f65bda
update find
arng40 e519b29
update prefix file pattern
arng40 09cea71
move to script
arng40 716ce69
fix rule ^^
arng40 a7f4a14
test perm
arng40 fad5944
add write
arng40 d3a6d9c
give perm
arng40 56eebfc
give perm
arng40 933dcc0
attempt perm
arng40 fc78670
remove if statement
arng40 3716bf2
test ls
arng40 d2eddbd
test another pwd
arng40 e59d2f0
fix cd
arng40 5c43982
add src
arng40 883ba54
go to src
arng40 02e26e1
remove prefix
arng40 a24ff21
sabotage code
arng40 e28b1c2
missing :
arng40 27657f6
display info at the end
arng40 f48fc29
check str
arng40 cb5754e
wrong varaible
arng40 4aeafa3
echo
arng40 e9e58c2
simplify
arng40 0792e88
remove done
arng40 14d9399
remove bracket
arng40 b7a5e53
add more std
arng40 7ed6c89
update logic
arng40 1b6654e
fix std
arng40 a4d11fd
style
arng40 198e895
remove lr
arng40 a95fba7
set stdUnorderedMap
arng40 239fb10
vector rule
arng40 87d05fe
add common
arng40 010d4bc
replace std::vector
arng40 5f6c1ad
revert on stdContainerWrapper
arng40 35a5aa4
echo file
arng40 64479d0
another echo
arng40 be824c6
add id cond
arng40 0845150
stdVector
arng40 2a96409
missing file
arng40 1d0f7f7
test for constituve
arng40 a47e596
try refacto with func
arng40 411913e
clean the code + test with file
arng40 d10651d
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 ae7e57c
fix declaration
arng40 b30ef2a
Merge branch 'feat/dudes/add-code-rules' of https://github.com/GEOS-D…
arng40 0dbd595
log
arng40 7f5aa44
update echo
arng40 84d15e9
refacto find cmd
arng40 bc8e010
remove exclude find
arng40 74cad67
remove log + revert
arng40 44f564e
update find command
arng40 46a0cf0
remove type f
arng40 addf93f
remove var from find
arng40 cf5fea6
reset find
arng40 3444008
revert loop
arng40 72e8258
update loop
arng40 10d7a2e
update code
arng40 2ebbc31
enforce code
arng40 a1b5b2f
echo file
arng40 92a66f3
fix loop
arng40 e207a68
revert some ci change + remove echo
arng40 d2b7019
print all path + some refacto
arng40 f73cb6d
remove debug log
arng40 c8d97a4
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 1632aee
uncrustify
arng40 679db25
factorize duplicated code
arng40 90f9dba
simplify functions
arng40 39389fd
centralize declaration of forbedden expression
arng40 eb30bc1
syntax correction
arng40 048aa63
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 eb195f4
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 3921b7a
add code rules in check_all_tests_succedeed
arng40 cc71431
renaming
arng40 0112f20
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 c7b0d76
♻️ name clarity refactor
MelReyCG 77d4a16
Merge branch 'develop' into feat/dudes/add-code-rules
MelReyCG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| #!/bin/bash | ||
|
|
||
|
|
||
| ################################ | ||
| ## I. Function initializations | ||
| ################################ | ||
|
|
||
| # while | ||
| # ... done < <(grep -n "std::map\s*<" "$file") | ||
| # Process the result of grep command as a file. | ||
| # This allows everything to be handled in the same shell environment. | ||
| check_container_usage() { | ||
| local container_name="$1" | ||
| local str=" Found forbidden ${container_name} usage in: $file"$'\n' | ||
|
|
||
| if grep -q "${container_name}\s*<" "$file"; then | ||
| while IFS= read -r line; do | ||
| str+=" $line"$'\n' | ||
| done < <(grep -n "${container_name}\s*<" "$file") | ||
|
|
||
| ERRORS_CONTAINER[$container_name]+="$str" | ||
| ((FORBIDDEN_CONTAINER_MAP["$container_name"]++)) | ||
| fi | ||
| } | ||
|
|
||
| print_violation() | ||
| { | ||
| local container_name="$1" | ||
|
|
||
| if [ "${FORBIDDEN_CONTAINER_MAP[$container_name]}" -eq 1 ];then | ||
| echo $'\n' | ||
| echo "ERROR: Forbidden $container_name usage detected" | ||
| echo "==========================================" | ||
|
|
||
| printf '%s' "${ERRORS_CONTAINER[$container_name]}" | ||
|
|
||
| fi | ||
| } | ||
|
|
||
| ################################ | ||
| ## II. GLOBAL INITIALIZATION | ||
| ################################ | ||
|
|
||
| FORBIDDEN_EXPRESSIONS=( | ||
| "std::map" | ||
| "std::unordered_map" | ||
| "std::vector" | ||
| ) | ||
|
|
||
| declare -A FORBIDDEN_CONTAINER_MAP=() | ||
| for exp in "${FORBIDDEN_EXPRESSIONS[@]}"; do | ||
| FORBIDDEN_CONTAINER_MAP["$exp"]=0 | ||
| done | ||
|
|
||
| declare -A ERRORS_CONTAINER=() | ||
| for exp in "${FORBIDDEN_EXPRESSIONS[@]}"; do | ||
| ERRORS_CONTAINER["$exp"]="" | ||
| done | ||
|
|
||
| FILEPATH_PREFIX="src/coreComponents/" | ||
| FILEPATH_SUBFOLDERS=( | ||
| "codingUtilities" | ||
| "common" | ||
| "dataRepository" | ||
| "constitutive" | ||
| "denseLinearAlgebra" | ||
| "discretizationMethods" | ||
| "events" | ||
| "fieldSpecification" | ||
| "fileIO" | ||
| "finiteElement" | ||
| "finiteVolume" | ||
| "functions" | ||
| "linearAlgebra" | ||
| "mainInterface" | ||
| "mesh" | ||
| "physicsSolvers" | ||
| ) | ||
|
|
||
| FILEPATH_EXCLUDE_PATTERNS=( | ||
| "Datatype.hpp" | ||
| "StdContainerWrappers.hpp" | ||
| "BufferOps_inline.hpp" | ||
| "BufferOps.hpp" | ||
| "PVTPackage" | ||
| "hdf5_interface" | ||
| ) | ||
|
|
||
| FILE_PATH_ARGS=() | ||
| for pattern in "${FILEPATH_SUBFOLDERS[@]}"; do | ||
| if [ -d "${FILEPATH_PREFIX}${pattern}" ]; then | ||
| FILE_PATH_ARGS+=("${FILEPATH_PREFIX}${pattern}") | ||
| fi | ||
| done | ||
|
|
||
| EXCLUDED_NAME_PATTERNS=() | ||
| for pattern in "${FILEPATH_EXCLUDE_PATTERNS[@]}"; do | ||
| if [[ ! "$pattern" == *".hpp"* ]]; then | ||
| EXCLUDED_NAME_PATTERNS+=( -path "*/$pattern" -prune -o ) | ||
| else | ||
| EXCLUDED_NAME_PATTERNS+=( -name "*${pattern}" -prune -o ) | ||
| fi | ||
| done | ||
|
|
||
| echo "======================================================" | ||
| echo -e " TREE LIST OF FILES FOUND " | ||
| echo "======================================================" | ||
|
|
||
| if [ ${#FILE_PATH_ARGS[@]} -gt 0 ]; then | ||
| find "${FILE_PATH_ARGS[@]}" "${EXCLUDED_NAME_PATTERNS[@]}" -type d -print | sort | while IFS= read -r dir; do | ||
| echo -e "->" $(echo "$dir" | sed 's/[]^$*.[]/\\&/g' | sed 's/\// |---/g') | ||
| done | ||
| fi | ||
|
|
||
| ARRAY_FILES=() | ||
| # mapfile used for reading inMAPput lines into an array; -d $'\0': Specifies that the delimiter is (\0). | ||
| # -print0 : ask find to separate file paths by '\0' | ||
| mapfile -d $'\0' ARRAY_FILES < <(find "${FILE_PATH_ARGS[@]}" "${EXCLUDED_NAME_PATTERNS[@]}" \ | ||
| -type f \( -name "*.hpp" -o -name "*.cpp" -o -name "*.hpp.template" -o -name "*.cpp.template" \) \ | ||
| -print0 2>/dev/null) | ||
|
|
||
| ################################ | ||
| ## III. MAIN LOOP | ||
| ################################ | ||
|
|
||
| for file in "${ARRAY_FILES[@]}"; do | ||
| for container_name in "${!FORBIDDEN_CONTAINER_MAP[@]}"; do | ||
| check_container_usage "$container_name" | ||
| done | ||
| done | ||
|
|
||
| # Print section | ||
| for key in "${!FORBIDDEN_CONTAINER_MAP[@]}"; do | ||
| if [[ "${FORBIDDEN_CONTAINER_MAP[$key]}" == "1" ]]; then | ||
| echo $'\n' | ||
| echo "----------------------------------------" | ||
| echo "SUMMARY: Code rule violations found" | ||
| echo "----------------------------------------" | ||
|
|
||
| for container_name in "${!FORBIDDEN_CONTAINER_MAP[@]}"; do | ||
| print_violation "$container_name" | ||
| done | ||
|
|
||
| echo "" | ||
| exit 1; | ||
| fi | ||
| done | ||
|
|
||
| echo $'\n' | ||
| echo "No code rule violations found" | ||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.