{"id":27556324,"url":"https://github.com/enceradeira/mudguard","last_synced_at":"2026-05-18T14:37:28.008Z","repository":{"id":52287952,"uuid":"245804981","full_name":"Enceradeira/mudguard","owner":"Enceradeira","description":"Mudguard helps your ruby project not becoming a 'Big ball of mud'","archived":false,"fork":false,"pushed_at":"2024-05-16T18:49:35.000Z","size":155,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T13:24:09.263Z","etag":null,"topics":["clean-architecture","design","rails","rubocop","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Enceradeira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-08T11:51:19.000Z","updated_at":"2021-05-01T15:05:53.000Z","dependencies_parsed_at":"2022-08-20T13:10:55.154Z","dependency_job_id":null,"html_url":"https://github.com/Enceradeira/mudguard","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enceradeira%2Fmudguard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enceradeira%2Fmudguard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enceradeira%2Fmudguard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enceradeira%2Fmudguard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Enceradeira","download_url":"https://codeload.github.com/Enceradeira/mudguard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249761088,"owners_count":21321851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","design","rails","rubocop","ruby"],"created_at":"2025-04-19T18:15:21.828Z","updated_at":"2025-10-28T10:42:04.212Z","avatar_url":"https://github.com/Enceradeira.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mudguard\n\n**Mudguard** is a Ruby static code analyzer that investigates the coupling of modules in your source code. Mudguard\nprevents your code from becoming a [Big ball of mud](http://www.laputan.org/mud/) and helps implementing and\nmaintaining an intended design.\n\nMudguard is inspired by\n* [Rubocop](https://github.com/rubocop-hq/rubocop)\n* Clean Architecture by Robert C. Martin (ISBN-13: 978-0-13-449416-6)\n* having seen many larger code bases in a sorrow state\n* my inability to efficiently break up application code into gems or rails engines\n\n# Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mudguard'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install mudguard\n\n## Quickstart\n```\n$ cd my/cool/ruby/project\n$ mudguard\n```\n\nMudguard creates on it's first run a file called **.mudguard.yml** which is used to configure **design policies** \ngoverning your code. A .mudguard.yml could look like:\n```\n'./**/*.rb': # all code\n  # all code can depend on siblings in same module or class\n  - ^(::.+)(::[^:]+)* -\u003e \\1(::[^:]+)*$\n  # all code can depend on certain types\n  - .* -\u003e ::(String|SecureRandom|Container|Time|Date|JSON|Object|Hash)$\n\n  # in all code module Application can depend on module Domain\n  - ^::Application(::[^:]+)* -\u003e ::(Domain)(::[^:]+)*$\n  # in all code module Infrastructure can depend on module Application\n  - ^::Infrastructure(::[^:]+)* -\u003e ::(Application)(::[^:]+)*$\n\n'spec/**/*.rb': # spec code\n  # Only in test code can we use RSpec, Timecop and Exception\n  - .* -\u003e ::(RSpec|Timecop|Exception)$\n``` \n\n## The .mudguard.yml\nThe .mudguard.yml defines scopes and policies. A policy defines which dependencies are inside that scope permissible:\n```\nscope1:\n    - policy 1\n    - policy 2\nscope2:\n    - policy 3\n```\nThe **scope** is a [glob-pattern](https://en.wikipedia.org/wiki/Glob_(programming)) and defines to which files a set\nof policies apply. For example a value `lib/docker/**/*.rb` defines a scope containing all Ruby files inside \nfolder lib/docker. \n\nA **policy** is a [regular expression](https://ruby-doc.org/core-2.5.1/Regexp.html) matching one or a set of \ndependencies that are permissible inside that scope. Mudguard represents a **dependency** as a symbol in form \nof `X -\u003e Y` meaning \"X depends on Y\". See following examples:\n\n| Policy | matched Dependency|  Explanation |\n| --- | --- | --- |\n| `^::A -\u003e ::B$` | `::A -\u003e ::B` |Module A can depend on module or constant B |\n| `^::Infrastructure -\u003e ::Rails$` | `::Infrastructure -\u003e ::Rails` |Module Infrastructure can depend on Rails |\n| `^::Infrastructure(::[^:]+)* -\u003e ::ActiveRecord$` | `::Infrastructure::Logger -\u003e ::ActiveRecord` or `::Infrastructure::Persistence -\u003e ::ActiveRecord`|Module Infrastructure and its submodules can depend on ActiveRecord |\n| `.*   -\u003e ::Exception$` | `::Api::Gateway -\u003e ::Exception` or `::Logger -\u003e ::Gateway` |Any module can depend on class Exception | \n\nAny dependency for which Mudguard doesn't find a matching policy is reported as an impermissible dependency.\n\n## Outlook\nUsing regular expressions as policies is very flexible but difficult to use. Furthermore certain patterns used in \nthe regular expressions do repeat. It might be useful to replace regular expressions in future with a specific language\nto describe permissible dependencies. Any thoughts on that?\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Enceradeira/mudguard.\n This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Mudguard project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mudguard/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenceradeira%2Fmudguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenceradeira%2Fmudguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenceradeira%2Fmudguard/lists"}