Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
6f8f1c0
add-code-rules
arng40 Nov 18, 2025
243af07
comment jobs not needed
arng40 Nov 18, 2025
7754898
try this
arng40 Nov 18, 2025
29f0ed6
remove ctest testcoderule
arng40 Nov 18, 2025
3d2782a
try to add some target
arng40 Nov 18, 2025
38748b0
relaunch ci
arng40 Nov 18, 2025
21956b3
forget 1 target
arng40 Nov 18, 2025
183262c
test code for detecting std::map
arng40 Nov 18, 2025
1a50cc9
force to true
arng40 Nov 19, 2025
4004d12
log
arng40 Nov 19, 2025
42d6f5b
more log
arng40 Nov 19, 2025
6a87699
print pwd
arng40 Nov 19, 2025
3ae12c4
test with regex
arng40 Nov 19, 2025
06b6d8f
fix
arng40 Nov 19, 2025
9f65bda
update find
arng40 Nov 19, 2025
e519b29
update prefix file pattern
arng40 Nov 19, 2025
09cea71
move to script
arng40 Nov 19, 2025
716ce69
fix rule ^^
arng40 Nov 19, 2025
a7f4a14
test perm
arng40 Nov 19, 2025
fad5944
add write
arng40 Nov 19, 2025
d3a6d9c
give perm
arng40 Nov 19, 2025
56eebfc
give perm
arng40 Nov 19, 2025
933dcc0
attempt perm
arng40 Nov 19, 2025
fc78670
remove if statement
arng40 Nov 19, 2025
3716bf2
test ls
arng40 Nov 19, 2025
d2eddbd
test another pwd
arng40 Nov 19, 2025
e59d2f0
fix cd
arng40 Nov 19, 2025
5c43982
add src
arng40 Nov 19, 2025
883ba54
go to src
arng40 Nov 19, 2025
02e26e1
remove prefix
arng40 Nov 19, 2025
a24ff21
sabotage code
arng40 Nov 19, 2025
e28b1c2
missing :
arng40 Nov 19, 2025
27657f6
display info at the end
arng40 Nov 19, 2025
f48fc29
check str
arng40 Nov 19, 2025
cb5754e
wrong varaible
arng40 Nov 19, 2025
4aeafa3
echo
arng40 Nov 19, 2025
e9e58c2
simplify
arng40 Nov 19, 2025
0792e88
remove done
arng40 Nov 19, 2025
14d9399
remove bracket
arng40 Nov 19, 2025
b7a5e53
add more std
arng40 Nov 19, 2025
7ed6c89
update logic
arng40 Nov 19, 2025
1b6654e
fix std
arng40 Nov 19, 2025
a4d11fd
style
arng40 Nov 19, 2025
198e895
remove lr
arng40 Nov 19, 2025
a95fba7
set stdUnorderedMap
arng40 Nov 19, 2025
239fb10
vector rule
arng40 Nov 19, 2025
87d05fe
add common
arng40 Nov 19, 2025
010d4bc
replace std::vector
arng40 Nov 19, 2025
5f6c1ad
revert on stdContainerWrapper
arng40 Nov 19, 2025
35a5aa4
echo file
arng40 Nov 19, 2025
64479d0
another echo
arng40 Nov 19, 2025
be824c6
add id cond
arng40 Nov 19, 2025
0845150
stdVector
arng40 Nov 19, 2025
2a96409
missing file
arng40 Nov 19, 2025
1d0f7f7
test for constituve
arng40 Nov 19, 2025
a47e596
try refacto with func
arng40 Nov 19, 2025
411913e
clean the code + test with file
arng40 Nov 20, 2025
d10651d
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 Nov 20, 2025
ae7e57c
fix declaration
arng40 Nov 20, 2025
b30ef2a
Merge branch 'feat/dudes/add-code-rules' of https://github.com/GEOS-D…
arng40 Nov 20, 2025
0dbd595
log
arng40 Nov 20, 2025
7f5aa44
update echo
arng40 Nov 20, 2025
84d15e9
refacto find cmd
arng40 Nov 20, 2025
bc8e010
remove exclude find
arng40 Nov 20, 2025
74cad67
remove log + revert
arng40 Nov 20, 2025
44f564e
update find command
arng40 Dec 1, 2025
46a0cf0
remove type f
arng40 Dec 1, 2025
addf93f
remove var from find
arng40 Dec 1, 2025
cf5fea6
reset find
arng40 Dec 1, 2025
3444008
revert loop
arng40 Dec 1, 2025
72e8258
update loop
arng40 Dec 1, 2025
10d7a2e
update code
arng40 Dec 1, 2025
2ebbc31
enforce code
arng40 Dec 1, 2025
a1b5b2f
echo file
arng40 Dec 2, 2025
92a66f3
fix loop
arng40 Dec 2, 2025
e207a68
revert some ci change + remove echo
arng40 Dec 2, 2025
d2b7019
print all path + some refacto
arng40 Dec 3, 2025
f73cb6d
remove debug log
arng40 Dec 3, 2025
c8d97a4
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 Dec 4, 2025
1632aee
uncrustify
arng40 Dec 5, 2025
679db25
factorize duplicated code
arng40 Dec 8, 2025
90f9dba
simplify functions
arng40 Dec 8, 2025
39389fd
centralize declaration of forbedden expression
arng40 Dec 8, 2025
eb30bc1
syntax correction
arng40 Dec 8, 2025
048aa63
Merge branch 'develop' into feat/dudes/add-code-rules
arng40 Dec 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ jobs:
RUNS_ON: ubuntu-22.04
USE_SCCACHE: false

check_code_rules:
needs: [is_not_draft_pull_request]
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/[email protected]
with:
submodules: false
lfs: false
fetch-depth: 0
sparse-checkout: |
scripts
src
- name: Check the code rules
run: "scripts/check_code_rules.sh"
Comment on lines +153 to +154
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it no longer grouped with the code style & docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not executed the same way as code style & docs

Copy link
Contributor

@MelReyCG MelReyCG Dec 11, 2025

Choose a reason for hiding this comment

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

So, why isn't it executed the same way? I don't know why the process has to be different than uncrustify check.

And, if it have to remain a job, why isn't check_code_rules in check_that_all_jobs_succeeded? As you're proposing, it is only advisory.


# Matrix containing all the CPU build.
# Those are quite fast and can efficiently benefit from the `sccache' tool to make them even faster.
cpu_builds:
Expand Down
151 changes: 151 additions & 0 deletions scripts/check_code_rules.sh
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

FILE_PREFIX="src/coreComponents/"
FILE_PATTERNS=(
"codingUtilities"
"common"
"dataRepository"
"constitutive"
"denseLinearAlgebra"
"discretizationMethods"
"events"
"fieldSpecification"
"fileIO"
"finiteElement"
"finiteVolume"
"functions"
"linearAlgebra"
"mainInterface"
"mesh"
"physicsSolvers"
)

EXCLUDE_PATTERNS=(
"Datatype.hpp"
"StdContainerWrappers.hpp"
"BufferOps_inline.hpp"
"BufferOps.hpp"
"PVTPackage"
"hdf5_interface"
)

FILE_PATH_ARGS=()
for pattern in "${FILE_PATTERNS[@]}"; do
if [ -d "${FILE_PREFIX}${pattern}" ]; then
FILE_PATH_ARGS+=("${FILE_PREFIX}${pattern}")
fi
done

EXCLUDE_EXPRESSION=()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, does it excludes?

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 make it clearer

Copy link
Contributor

@MelReyCG MelReyCG Dec 11, 2025

Choose a reason for hiding this comment

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

Suggested change
EXCLUDE_EXPRESSION=()
EXCLUDED_NAMES=()
Suggested change
EXCLUDE_EXPRESSION=()
EXCLUDED_NAME_PATTERNS_=()

for pattern in "${EXCLUDE_PATTERNS[@]}"; do
if [[ ! "$pattern" == *".hpp"* ]]; then
EXCLUDE_EXPRESSION+=( -path "*/$pattern" -prune -o )
else
EXCLUDE_EXPRESSION+=( -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[@]}" "${EXCLUDE_EXPRESSION[@]}" -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[@]}" "${EXCLUDE_EXPRESSION[@]}" \
-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
2 changes: 1 addition & 1 deletion src/coreComponents/codingUtilities/RTTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void printTypeSummary()

string rtTypes::getTypeName( std::type_index const key )
{
static const std::unordered_map< std::type_index, string > type_names =
static const stdUnorderedMap< std::type_index, string > type_names =
{
{std::type_index( typeid(integer)), "integer"},
{std::type_index( typeid(real32)), "real32"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST( testGeosxTraits, HasMemberFunction_at )
static_assert( HasMemberFunction_at< stdVector< int > >, "Should be true." );
static_assert( HasMemberFunction_at< stdVector< double > >, "Should be true." );
static_assert( HasMemberFunction_at< stdMap< int, string > >, "Should be true." );
static_assert( HasMemberFunction_at< std::unordered_map< int, string > >, "Should be true." );
static_assert( HasMemberFunction_at< stdUnorderedMap< int, string > >, "Should be true." );

static_assert( !HasMemberFunction_at< int >, "Should be false." );
static_assert( !HasMemberFunction_at< stdMap< string, string > >, "Should be false." );
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/MemoryInfos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void MemoryLogging::memoryStatsReport() const
MPI_Comm_size( MPI_COMM_WORLD, &size );
size_t nbRank = (std::size_t)size;
// Get a list of all the allocators and sort it so that it's in the same order on each rank.
std::vector< string > allocatorNames = rm.getAllocatorNames();
stdVector< string > allocatorNames = rm.getAllocatorNames();
std::sort( allocatorNames.begin(), allocatorNames.end() );

// If each rank doesn't have the same number of allocators you can't aggregate them.
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/TypeDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ template< typename LIST, std::size_t ... Is >
auto const & getTypeMap( LIST, std::integer_sequence< std::size_t, Is... > )
{
using KeyType = decltype( createTypeIndexTuple( camp::first< LIST > {} ) );
static std::unordered_map< KeyType, std::size_t, tuple_hash > const result = { { createTypeIndexTuple( camp::at_t< LIST, camp::num< Is > >{} ), Is } ... };
static stdUnorderedMap< KeyType, std::size_t, tuple_hash > const result = { { createTypeIndexTuple( camp::at_t< LIST, camp::num< Is > >{} ), Is } ... };
return result;
}

Expand Down
10 changes: 5 additions & 5 deletions src/coreComponents/common/format/table/TableFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ string TableCSVFormatter::toString< TableData >( TableData const & tableData ) c
{
if( tableData.getErrorsList().hasErrors() )
{
std::vector< string > cpyErrors = tableData.getErrorsList().getErrors();
stdVector< string > cpyErrors = tableData.getErrorsList().getErrors();
getErrorsList().appendErrors( cpyErrors );
}

Expand Down Expand Up @@ -518,8 +518,8 @@ void TableTextFormatter::populateErrorCellsLayout( PreparedTableLayout const & t
{
errorCellsLayout.push_back(
{
std::vector< TableLayout::CellLayout >( nbCells,
TableLayout::CellLayout( CellType::MergeNext ) ),
stdVector< TableLayout::CellLayout >( nbCells,
TableLayout::CellLayout( CellType::MergeNext ) ),
1 // subLines count
} );
errorCellsLayout.back().cells.back().m_cellType = CellType::Value;
Expand All @@ -531,8 +531,8 @@ void TableTextFormatter::populateErrorCellsLayout( PreparedTableLayout const & t

errorCellsLayout.push_back(
{
std::vector< TableLayout::CellLayout >( nbCells,
TableLayout::CellLayout( CellType::Separator ) ),
stdVector< TableLayout::CellLayout >( nbCells,
TableLayout::CellLayout( CellType::Separator ) ),
1 // subLines count
} );

Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/format/table/TableLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class TableLayout
/**
* @return The view on each cell line.
*/
std::vector< string_view > & getLines()
stdVector< string_view > & getLines()
{ return m_lines; }

/**
Expand Down
10 changes: 5 additions & 5 deletions src/coreComponents/common/format/table/TableTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TableErrorListing
void clear();

/// The iterator alias for the errors vector of string
using Iterator = std::vector< string >::const_iterator;
using Iterator = stdVector< string >::const_iterator;

/**
* @return An Iterator pointing to the first element of the errors vector
Expand All @@ -80,24 +80,24 @@ class TableErrorListing
* @brief Append a vector of string to the errors vector.
* @param errors A vector of string to append
*/
void appendErrors( std::vector< string > & errors )
void appendErrors( stdVector< string > & errors )
{ m_errorList.insert( m_errorList.end(), errors.begin(), errors.end() );}

/**
* @return A const reference to the errors vector.
*/
std::vector< string > const & getErrors() const
stdVector< string > const & getErrors() const
{ return m_errorList; }

/**
* @return A reference to the errors vector.
*/
std::vector< string > & getErrors()
stdVector< string > & getErrors()
{ return m_errorList; }

private:
/// Contain all the errors to display at the end of the table
std::vector< string > m_errorList;
stdVector< string > m_errorList;
};

inline void TableErrorListing::addError( string_view text )
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/common/logger/ErrorHandling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class ErrorLogger
/// the source location line corresponding to the error in the code (default is 0)
integer m_line = 0;
/// Additional information about the error in the input file
std::vector< ErrorContext > m_contextsInfo;
stdVector< ErrorContext > m_contextsInfo;
/// the stack trace
std::vector< std::string > m_sourceCallStack;
stdVector< std::string > m_sourceCallStack;

/**
* @brief Construct a default Error Message
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/unitTests/testDataTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TEST( testDataTypes, testBoundChecking )
// std::cout <<" sdsfs "<< mapBoundsChecking.get_inserted(0)<< std::endl;
// std::cout << mapBoundsChecking.get_inserted(1);

internal::StdMapWrapper< std::unordered_map< integer, integer >, true > unorderedMapBoundsChecking{{0, 1}};
internal::StdMapWrapper< stdUnorderedMap< integer, integer >, true > unorderedMapBoundsChecking{{0, 1}};
EXPECT_THROW( {
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/constitutive/ConstitutiveBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class ConstitutiveBase : public dataRepository::Group
/**
* @return A const vector containing all fields
*/
std::vector< std::string > const & getUserFields() const
stdVector< std::string > const & getUserFields() const
{
return m_userFields;
}
Expand All @@ -189,7 +189,7 @@ class ConstitutiveBase : public dataRepository::Group
bool m_isClone;

// Vector containing all fields registered with `registerField()`
std::vector< std::string > m_userFields;
stdVector< std::string > m_userFields;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ bool KValueFlashParameters< NUM_PHASE >::validateKValues( MultiFluidBase const *

if( !tableData.getTableDataRows().empty())
{
std::vector< TableLayout::Column > columns;
stdVector< TableLayout::Column > columns;
columns.emplace_back( TableLayout::Column().setName( "Phase" ).setValuesAlignment( TableLayout::Alignment::left ) );
columns.emplace_back( TableLayout::Column().setName( "Pressure" ).setValuesAlignment( TableLayout::Alignment::right ) );
columns.emplace_back( TableLayout::Column().setName( "Temperature" ).setValuesAlignment( TableLayout::Alignment::right ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace constitutive
namespace compositional
{

static std::unordered_map< PhaseType, std::string > const phase_aliases{
static stdUnorderedMap< PhaseType, std::string > const phase_aliases{
{PhaseType::LIQUID, "liquid,liq,oil"},
{PhaseType::VAPOUR, "gas,vap,vapor,vapour"},
{PhaseType::AQUEOUS, "wat,water,aqueous"}
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/constitutive/unitTests/TestFluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct Fluid
7.45513e-02, 1.80000e+07, 3.47000e+03, 6.25000e-04, -1.21200e-01, 3.05992e-05, // KCL (potassium chloride)
};

static std::unordered_map<integer,string> const componentNames;
static stdUnorderedMap<integer,string> const componentNames;
/* UNCRUSTIFY-ON */
};

Expand Down Expand Up @@ -199,7 +199,7 @@ class TestFluid
};

/* UNCRUSTIFY-OFF */
std::unordered_map<integer,string> const Fluid::componentNames = {
stdUnorderedMap<integer,string> const Fluid::componentNames = {
{ H2O, "H2O" }, // water
{ CO2, "CO2" }, // carbon dioxide
{ N2, "N2" }, // nitrogen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST_P( SoreideWhitsonSolubilityTestFixture, testSolubility )
/* UNCRUSTIFY-OFF */
// Soreide-Whitson correlations work only with "true" values of component parameters
// kij_NA is the binary interation coefficient in the gas phase (see Table 5 Soreide-Whitson (1992))
std::unordered_map<integer, std::array<real64 const, 6> const> const componentDatabase = {
stdUnorderedMap<integer, std::array<real64 const, 6> const> const componentDatabase = {
// Mw Pc Tc Vc Ac kij_NA
{Fluid::H2O, { 1.80153e-02, 2.20640e+07, 6.47096e+02, 5.59480e-05, 3.44300e-01, 0.0000 }},
{Fluid::CO2, { 4.40095e-02, 7.37730e+06, 3.04128e+02, 9.41185e-05, 2.23940e-01, 0.1896 }},
Expand Down
Loading
Loading