Repository navigation
Use StructArmed on QA - #228
Open
samsonasik wants to merge 1 commit into
Open
samsonasik wants to merge 1 commit into
samsonasik wants to merge 1 commit into
Conversation
Signed-off-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Ready for review 👍 |
Member
|
Hey @samsonasik thanks for the PR and the consideration!! It may take a couple days for us to make a decision on this. We need that time to take a look at what StructArmed provides beyond what Mago Guard will provide. |
Contributor
Author
|
@tyrsson that's fine 👍 , for additional information, StructArmed can do guard + more additional features to support it, like finalize classes, clean up unused class/functions, etc), also, it is already very fast, here StructArmed speed, in action, analyze 2215 files only in 0.6 seconds :) structarmed-speed-in-action.mov |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Types of changes
Checklist:
Description
Hi, this PR add StructArmed to QA
https://github.com/boundwize/structarmed
It is a configurable PHP architecture guards with built in presets (psr4, mvc, and so on).
It already used by PHP frameworks:
This PR apply
StructArmedwith register:Applied with single command:
I also enable ruleset so it show more ability of layering setup to define which layers each layer is allowed to depend on.
Register to github workflow.
Motivation and Context
phpdb already enforces formatting, linting, static analysis, and mutation score, but nothing enforces the layering between
Adapter,Sql,ResultSet,Metadata, and the gateways. Today ause PhpDb\Adapter\...added to a predicate or a DDL column would pass every existing check. StructArmed makes that layering an executable rule: changing the architecture on purpose becomes a one-line diff instructarmed.phpreviewed in the same PR, while changing it by accident fails CI with a message naming the class, the dependency, and both layers.The PSR4 preset already paid for itself once: it caught the stale
PhpDbBenchmark\mapping incomposer.jsonpointing at atest/benchmark/directory that does not exist and a namespace nothing references.How the layers and ruleset are set up:
src/is its own layer vialayer(), plusConfigProvider.phpon its own (34 layers in total). Where a directory contains sub-directories that are layers themselves, the parent uses the thirdexcludeargument so each class belongs to exactly one layer, for exampleSqlexcludesArgument,Ddl,Exception,Platform, andPredicate.+Layerwherever a layer builds on another, so it inherits the base layer's allowed dependencies and the lists stay short, for example'SqlPredicate' => ['+SqlArgument', '+SqlPredicateException'].Adapter↔Adapter\Driver↔ResultSetandSql↔Sql\Argument/Sql\Platform/Sql\Predicateare allowed as-is but are now explicit and visible in one file.Some of what it guarantees going forward:
*\Exceptionnamespaces andMetadata\Objectstay leaf layers.Sql\Argument,Sql\Predicate, andSql\Ddl\*stay pure SQL abstraction and cannot reachAdapter,ResultSet, or the gateways.ResultSetonly knowsAdapter\Driver;Metadataonly reachesAdapter.ContainerandConfigProviderare the only layers allowed to see the whole wiring.How has this been tested?
vendor/bin/structarmed analyseon this branch reportsNo violations found.(StructArmed 0.18.11, PHP 8.3).+references confirms the only over-allowance is the baseExceptionlayer for layers that use their own*Exceptionsub-layer, plus three small ones (AdapterDriver→AdapterException,SqlDdlIndex→SqlException,RowGatewayFeature→Adapter).composer testpasses:OK (2089 tests, 4038 assertions).qa-structarmedjob runs on this PR in the existingcontinuous-integration.ymlworkflow.Screenshots (if appropriate):
Please let me know if this need simplification, reduce config, or split into multiple PRs.