From dd6affbe9bd4a9123097664a1daaf5770c5d480c Mon Sep 17 00:00:00 2001 From: Connor Aird Date: Fri, 23 May 2025 16:06:07 +0100 Subject: [PATCH 1/5] Adding extra info about setting custom rules with fortitude --- formatting/fortitude.md | 8 ++++++-- formatting/fortitude.toml | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/formatting/fortitude.md b/formatting/fortitude.md index ef1039a..5d388c0 100644 --- a/formatting/fortitude.md +++ b/formatting/fortitude.md @@ -6,7 +6,8 @@ A tool for installing, i.e. `pip` or `homebrew` ## Installation -To install fortitude we can utilise the provided `pyproject.toml` by following the instructions in [the pre-commit install instructions](../README.md#pre-commit). The [quickstart page](https://fortitude.readthedocs.io/en/stable/#quickstart) for Fortitude details multiple other ways of installing the tool. +To install fortitude we can utilise the provided `pyproject.toml` by following the instructions in [the pre-commit install instructions](../README.md#pre-commit). +The [quickstart page](https://fortitude.readthedocs.io/en/stable/#quickstart) for Fortitude details multiple other ways of installing the tool. ## Usage in this repo @@ -16,7 +17,10 @@ This repo has been formatted with Fortitude. To check this repo with Fortitude, fortitude --config-file formatting/fortitude.toml check ``` -The config file, [fortitude.toml](./fortitude.toml), we have provided in the above command contains our rules which alter the [default fortitude rules](https://fortitude.readthedocs.io/en/stable/rules/). +The config file, [fortitude.toml](./fortitude.toml), we have provided in the above command contains our rules which alter the +[default fortitude rules](https://fortitude.readthedocs.io/en/stable/rules/). + + ### pre-commit diff --git a/formatting/fortitude.toml b/formatting/fortitude.toml index 5322969..31b317a 100644 --- a/formatting/fortitude.toml +++ b/formatting/fortitude.toml @@ -1,5 +1,9 @@ [check] +# A set of rules we ignore. Fortitude will not enforce these rules. ignore = [ "C003", # 'implicit none' missing 'external' ] + +# A custom maxmum line length for our repo which will effect the +# behaviour of rule S001 (line-too-long) line-length = 132 From 182d07a4ab6e6ae75b560e75dcd71d257909ba80 Mon Sep 17 00:00:00 2001 From: connoraird Date: Tue, 26 Aug 2025 11:09:01 +0100 Subject: [PATCH 2/5] Move fortitude back into its own dir, switch to using requirements.txt and update docs --- .gitignore | 3 ++- .pre-commit-config.yaml | 2 +- README.md | 4 ++-- formatting/{ => fortitude}/fortitude.md | 2 +- formatting/{ => fortitude}/fortitude.toml | 0 pyproject.toml | 14 -------------- requirements.txt | 2 ++ testing/veggies/test_poisson_given_when_then.f90 | 14 -------------- 8 files changed, 8 insertions(+), 33 deletions(-) rename formatting/{ => fortitude}/fortitude.md (92%) rename formatting/{ => fortitude}/fortitude.toml (100%) delete mode 100644 pyproject.toml create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index d342869..7f1a277 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ build/ build-cmake/ *Temporary .vscode -*.egg-info \ No newline at end of file +*.egg-info +.venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f9e5a25..0c71b46 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,4 +7,4 @@ repos: # requires the `--config-file` option to be specified before the `check` subcommand # and the pre-commit hook correctly states check in the entry. - id: fortitude - entry: fortitude --config-file formatting/fortitude.toml check --force-exclude + entry: fortitude --config-file formatting/fortitude/fortitude.toml check --force-exclude diff --git a/README.md b/README.md index dad3cee..549d23b 100644 --- a/README.md +++ b/README.md @@ -108,11 +108,11 @@ fpm test [pre-commit](https://pre-commit.com/) is utilised within this repo. pre-commit is a tool to help enforce formatting standards as early as possible. pre-commit works by running a provided set of checks every time a `git commit` is attempted. -To utilise pre-commit, it must be installed locally. This can be done in several ways but the easiest is to use the provided `pyproject.toml` via... +To utilise pre-commit, it must be installed locally. This can be done in several ways but the easiest is to use the provided `requirements.txt` via... ``` python3 -m venv .venv source .venv/bin/activate -python -m pip install -e . +python -m pip install -r requirements.txt ``` Then, from the root of the repo, you start using pre-commit by running diff --git a/formatting/fortitude.md b/formatting/fortitude/fortitude.md similarity index 92% rename from formatting/fortitude.md rename to formatting/fortitude/fortitude.md index 5d388c0..7e5afd2 100644 --- a/formatting/fortitude.md +++ b/formatting/fortitude/fortitude.md @@ -6,7 +6,7 @@ A tool for installing, i.e. `pip` or `homebrew` ## Installation -To install fortitude we can utilise the provided `pyproject.toml` by following the instructions in [the pre-commit install instructions](../README.md#pre-commit). +To install fortitude we can utilise the provided `requirements.txt` by following the instructions in [the pre-commit install instructions](../../README.md#pre-commit). The [quickstart page](https://fortitude.readthedocs.io/en/stable/#quickstart) for Fortitude details multiple other ways of installing the tool. ## Usage in this repo diff --git a/formatting/fortitude.toml b/formatting/fortitude/fortitude.toml similarity index 100% rename from formatting/fortitude.toml rename to formatting/fortitude/fortitude.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index b7056c4..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[build-system] -build-backend = "setuptools.build_meta" -requires = [ - "setuptools", - "setuptools-scm", -] - -[project] -name = "fortran-tooling" -version = "0.0.1" -dependencies = [ - "fortitude-lint>=0.7.2", - "pre-commit>=4.2.0" -] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8b9a709 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fortitude-lint>=0.7.2 +pre-commit>=4.2.0 diff --git a/testing/veggies/test_poisson_given_when_then.f90 b/testing/veggies/test_poisson_given_when_then.f90 index ecb16c2..0c97c61 100644 --- a/testing/veggies/test_poisson_given_when_then.f90 +++ b/testing/veggies/test_poisson_given_when_then.f90 @@ -44,7 +44,6 @@ module veggies_poisson_given_when_then contains function test_poisson_given_when_then() result(test) - implicit none type(test_item_t) :: test character(len=:), allocatable :: file_name @@ -73,7 +72,6 @@ function test_poisson_given_when_then() result(test) end function test_poisson_given_when_then function load_data_file(input) result(output) - implicit none class(input_t), intent(in) :: input type(transformed_t) :: output @@ -109,7 +107,6 @@ function load_data_file(input) result(output) end function load_data_file function check_file_is_open(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -122,7 +119,6 @@ function check_file_is_open(input) result(result_) end function check_file_is_open function check_num_nodes(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -136,7 +132,6 @@ function check_num_nodes(input) result(result_) end function check_num_nodes function check_num_elements(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -150,7 +145,6 @@ function check_num_elements(input) result(result_) end function check_num_elements function check_num_boundary_points(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -164,7 +158,6 @@ function check_num_boundary_points(input) result(result_) end function check_num_boundary_points function check_element_to_node(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -180,7 +173,6 @@ function check_element_to_node(input) result(result_) end function check_element_to_node function check_vb_index(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -193,7 +185,6 @@ function check_vb_index(input) result(result_) end function check_vb_index function check_boundary_node_num(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -208,7 +199,6 @@ function check_boundary_node_num(input) result(result_) end function check_boundary_node_num function check_num_side_nodes(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -225,7 +215,6 @@ function check_num_side_nodes(input) result(result_) end function check_num_side_nodes function check_vb(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -241,7 +230,6 @@ function check_vb(input) result(result_) end function check_vb function check_vb1(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -254,7 +242,6 @@ function check_vb1(input) result(result_) end function check_vb1 function check_coordinates(input) result(result_) - implicit none class(input_t), intent(in) :: input type(result_t) :: result_ @@ -274,7 +261,6 @@ end function check_coordinates !! Constructors !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! function data_file_state_constructor() result(data_file_state) - implicit none type(data_file_state_t) :: data_file_state integer, parameter :: file_io = 200 From f140427dc113c52aaf5269e2c185a0ae6d1a5d84 Mon Sep 17 00:00:00 2001 From: connoraird Date: Tue, 26 Aug 2025 11:13:36 +0100 Subject: [PATCH 3/5] Link to dir in formatting readme --- formatting/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formatting/README.md b/formatting/README.md index 8aa4970..fa87352 100644 --- a/formatting/README.md +++ b/formatting/README.md @@ -4,4 +4,4 @@ | tool | description | Known issues | | ---- | ----------- | ------------ | -| [Fortitude](https://fortitude.readthedocs.io/en/stable/) | A [Ruff](https://docs.astral.sh/ruff/) style linter for Fortran. | | +| [Fortitude](./fortitude/) | A [Ruff](https://docs.astral.sh/ruff/) style linter for Fortran. | | From a641ef1a25b17b1dee601f60b69ac59858094175 Mon Sep 17 00:00:00 2001 From: Ilektra Christidi Date: Tue, 26 Aug 2025 13:32:57 +0100 Subject: [PATCH 4/5] Rename md file to be visible as README --- formatting/fortitude/{fortitude.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename formatting/fortitude/{fortitude.md => README.md} (100%) diff --git a/formatting/fortitude/fortitude.md b/formatting/fortitude/README.md similarity index 100% rename from formatting/fortitude/fortitude.md rename to formatting/fortitude/README.md From 16dea3dd6c37349bb1eccabef026976d3eea025b Mon Sep 17 00:00:00 2001 From: Ilektra Christidi Date: Tue, 26 Aug 2025 15:15:33 +0100 Subject: [PATCH 5/5] Fix broken link in README --- formatting/fortitude/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formatting/fortitude/README.md b/formatting/fortitude/README.md index 7e5afd2..70b6a48 100644 --- a/formatting/fortitude/README.md +++ b/formatting/fortitude/README.md @@ -24,7 +24,7 @@ The config file, [fortitude.toml](./fortitude.toml), we have provided in the abo ### pre-commit -We have also integrated Fortitude with pre-commit. To set this up, follow the [instructions on the main README.md](../README.md#pre-commit). +We have also integrated Fortitude with pre-commit. To set this up, follow the [instructions on the main README.md](../../README.md#pre-commit). Once this is set up, if you then try and commit a poorly formatted Fortran file... ```sh