diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 0dbb6e269..cf14b5b6a 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -10,10 +10,14 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' - name: Install dependencies run: | - sudo pip install cmake-format black + pip install cmake-format clang-format black - name: Clang Format run: ./script/clang-format --check diff --git a/lib/include/resdata/rd_file.hpp b/lib/include/resdata/rd_file.hpp index 9f073174a..d60e71dc6 100644 --- a/lib/include/resdata/rd_file.hpp +++ b/lib/include/resdata/rd_file.hpp @@ -16,9 +16,8 @@ extern "C" { #include #define RD_FILE_FLAGS_ENUM_DEFS \ - {.value = 1, .name = "RD_FILE_CLOSE_STREAM"}, { \ - .value = 2, .name = "RD_FILE_WRITABLE" \ - } + {.value = 1, .name = "RD_FILE_CLOSE_STREAM"}, \ + {.value = 2, .name = "RD_FILE_WRITABLE"} #define RD_FILE_FLAGS_ENUM_SIZE 2 typedef struct rd_file_struct rd_file_type; diff --git a/lib/include/resdata/rd_grid.hpp b/lib/include/resdata/rd_grid.hpp index fe15fdbf5..690fbcfbc 100644 --- a/lib/include/resdata/rd_grid.hpp +++ b/lib/include/resdata/rd_grid.hpp @@ -16,7 +16,7 @@ extern "C" { #endif #define RD_GRID_COORD_SIZE(nx, ny) (((nx) + 1) * ((ny) + 1) * 6) -#define RD_GRID_ZCORN_SIZE(nx, ny, nz) (((nx) * (ny) * (nz)*8)) +#define RD_GRID_ZCORN_SIZE(nx, ny, nz) (((nx) * (ny) * (nz) * 8)) #define RD_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids. #define RD_GRID_MAINGRID_LGR_NR 0 diff --git a/lib/include/resdata/rd_type.hpp b/lib/include/resdata/rd_type.hpp index fa6c7bcf4..57bbbd2b7 100644 --- a/lib/include/resdata/rd_type.hpp +++ b/lib/include/resdata/rd_type.hpp @@ -39,9 +39,8 @@ typedef enum { {.value = 2, .name = "RD_DOUBLE_TYPE"}, \ {.value = 3, .name = "RD_INT_TYPE"}, \ {.value = 4, .name = "RD_BOOL_TYPE"}, \ - {.value = 5, .name = "RD_MESS_TYPE"}, { \ - .value = 7, .name = "RD_STRING_TYPE" \ - } + {.value = 5, .name = "RD_MESS_TYPE"}, \ + {.value = 7, .name = "RD_STRING_TYPE"} /* Character data in restart format files comes as an array of fixed-length @@ -67,20 +66,15 @@ struct rd_type_struct { rd_data_type { RD_DOUBLE_TYPE, sizeof(double) } #define RD_BOOL \ rd_data_type { RD_BOOL_TYPE, sizeof(bool) } -#define RD_CHAR \ - rd_data_type { RD_CHAR_TYPE, RD_STRING8_LENGTH + 1 } -#define RD_MESS \ - rd_data_type { RD_MESS_TYPE, 0 } -#define RD_STRING(size) \ - rd_data_type { RD_STRING_TYPE, (size) + 1 } +#define RD_CHAR rd_data_type{RD_CHAR_TYPE, RD_STRING8_LENGTH + 1} +#define RD_MESS rd_data_type{RD_MESS_TYPE, 0} +#define RD_STRING(size) rd_data_type{RD_STRING_TYPE, (size) + 1} } #else #define RD_CHAR \ - (rd_data_type) { \ - .type = RD_CHAR_TYPE, .element_size = RD_STRING8_LENGTH + 1 \ - } + (rd_data_type){.type = RD_CHAR_TYPE, .element_size = RD_STRING8_LENGTH + 1} #define RD_INT \ (rd_data_type) { .type = RD_INT_TYPE, .element_size = sizeof(int) } #define RD_FLOAT \ @@ -89,10 +83,9 @@ struct rd_type_struct { (rd_data_type) { .type = RD_DOUBLE_TYPE, .element_size = sizeof(double) } #define RD_BOOL \ (rd_data_type) { .type = RD_BOOL_TYPE, .element_size = sizeof(bool) } -#define RD_MESS \ - (rd_data_type) { .type = RD_MESS_TYPE, .element_size = 0 } +#define RD_MESS (rd_data_type){.type = RD_MESS_TYPE, .element_size = 0} #define RD_STRING(size) \ - (rd_data_type) { .type = RD_STRING_TYPE, .element_size = (size) + 1 } + (rd_data_type){.type = RD_STRING_TYPE, .element_size = (size) + 1} #endif diff --git a/lib/include/resdata/rd_units.hpp b/lib/include/resdata/rd_units.hpp index 536bbcb05..1b4641024 100644 --- a/lib/include/resdata/rd_units.hpp +++ b/lib/include/resdata/rd_units.hpp @@ -6,8 +6,8 @@ extern "C" { #endif #define RD_UNITS_CUBIC(x) ((x) * (x) * (x)) -#define RD_UNITS_MILLI(x) ((x)*0.001) -#define RD_UNITS_MEGA(x) ((x)*1000000) +#define RD_UNITS_MILLI(x) ((x) * 0.001) +#define RD_UNITS_MEGA(x) ((x) * 1000000) #define RD_UNITS_LENGTH_INCH 0.0254 #define RD_UNITS_LENGTH_FEET 12 * RD_UNITS_LENGTH_INCH diff --git a/lib/include/resdata/rd_util.hpp b/lib/include/resdata/rd_util.hpp index 6fbc6fee6..870e5bd03 100644 --- a/lib/include/resdata/rd_util.hpp +++ b/lib/include/resdata/rd_util.hpp @@ -77,9 +77,8 @@ typedef enum { #define RD_PHASE_ENUM_DEFS \ {.value = 1, .name = "RD_OIL_PHASE"}, \ - {.value = 2, .name = "RD_GAS_PHASE"}, { \ - .value = 4, .name = "RD_WATER_PHASE" \ - } + {.value = 2, .name = "RD_GAS_PHASE"}, \ + {.value = 4, .name = "RD_WATER_PHASE"} #define RD_PHASE_ENUM_SIZE 3 typedef enum { diff --git a/lib/resdata/tests/rd_kw_fread.cpp b/lib/resdata/tests/rd_kw_fread.cpp index 55af4d2e1..c4a3d538a 100644 --- a/lib/resdata/tests/rd_kw_fread.cpp +++ b/lib/resdata/tests/rd_kw_fread.cpp @@ -76,7 +76,9 @@ void test_kw_io_charlength() { fortio_fclose(f); } - { test_assert_false(util_file_exists("TEST1")); } + { + test_assert_false(util_file_exists("TEST1")); + } { FILE *file = util_fopen("TEST2", "w"); diff --git a/lib/util/util.cpp b/lib/util/util.cpp index b720803aa..873e49a93 100644 --- a/lib/util/util.cpp +++ b/lib/util/util.cpp @@ -189,8 +189,8 @@ void util_endian_flip_vector(void *data, int element_size, int elements) { } #ifndef S_ISDIR -#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) -#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif static bool EOL_CHAR(char c) {