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

Mark controllers as "final" #1587

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

williamjallen
Copy link
Collaborator

Our controller inheritance hierarchy currently has two types of controllers: "abstract" controllers which provide useful helper functions, and "business" controllers which contain functions which are called by Laravel's routing system. We should never inherit from a "business" controller, since there should never be a need to inherit the business logic contained within. At the same time, an easy mistake to make is to inherit from BuildController rather than AbstractBuildController for example. To help enforce this, we can mark each "business" controller with the final keyword and use PHPStan to ensure that no controllers inherit from a "business" controller.

@williamjallen williamjallen added this pull request to the merge queue Aug 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 1, 2023
@williamjallen williamjallen added this pull request to the merge queue Aug 2, 2023
Merged via the queue into Kitware:master with commit 412430c Aug 2, 2023
1 check passed
@williamjallen williamjallen deleted the final-controllers branch August 2, 2023 14:28
github-merge-queue bot pushed a commit that referenced this pull request Aug 10, 2023
The `FilterController` class was created before
#1587 was merged, and is thus
missing the `final` designation.

`AbstractBuildController ` was missed amidst some logical conflicts when
previous PRs were merged and has been designated as `abstract`.

In the future, it might be interesting to create a PHPStan plugin which
ensures that all future controllers follow our naming and designation
conventions.
github-merge-queue bot pushed a commit that referenced this pull request Aug 31, 2023
CDash has a controller naming and designation convention, as discussed
in #1587. Since then, I have
forgotten to mark several new controllers as "final". I have added a
test to enforce these rules automatically, rather than relying upon
human reviewers to catch it.

As seen in the diff for this PR, this test is quite effective. It caught
the fact that the controllers in the Auth directory were not marked with
the "final" keyword.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants