{"id":30229614,"url":"https://github.com/evref-bl/moose-rule-engine","last_synced_at":"2026-02-08T22:34:18.211Z","repository":{"id":305694889,"uuid":"1018089263","full_name":"Evref-BL/Moose-Rule-Engine","owner":"Evref-BL","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-31T12:49:48.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-08-14T21:56:37.174Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Evref-BL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-11T15:31:45.000Z","updated_at":"2025-07-31T12:42:05.000Z","dependencies_parsed_at":"2025-07-29T16:07:27.929Z","dependency_job_id":null,"html_url":"https://github.com/Evref-BL/Moose-Rule-Engine","commit_stats":null,"previous_names":["evref-bl/moose-rule-engine"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Evref-BL/Moose-Rule-Engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evref-BL%2FMoose-Rule-Engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evref-BL%2FMoose-Rule-Engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evref-BL%2FMoose-Rule-Engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evref-BL%2FMoose-Rule-Engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Evref-BL","download_url":"https://codeload.github.com/Evref-BL/Moose-Rule-Engine/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Evref-BL%2FMoose-Rule-Engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29247970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T21:42:34.334Z","status":"ssl_error","status_checked_at":"2026-02-08T21:41:38.468Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-08-14T21:44:22.718Z","updated_at":"2026-02-08T22:34:18.182Z","avatar_url":"https://github.com/Evref-BL.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moose-Rule-Engine\n\n[![Continuous](https://github.com/Evref-BL/Moose-Rule-Engine/actions/workflows/continuous.yml/badge.svg)](https://github.com/Evref-BL/Moose-Rule-Engine/actions/workflows/continuous.yml)\n[![Coverage Status](https://coveralls.io/repos/github/Evref-BL/Moose-Rule-Engine/badge.svg?branch=develop)](https://coveralls.io/github/Evref-BL/Moose-Rule-Engine?branch=develop)\n\nMoose-Rule-Engine is a multi-language, rule-based engine designed for code analysis, automated remediation, and large-scale refactoring. \n\n---\n\n## Table of Contents\n\n1. [Features](#features)\n2. [Installation](#installation)\n   - [From Playground](#from-playground)\n   - [Baseline Dependency](#baseline-dependency)\n3. [Usage](#usage)\n4. [Core Concepts](#core-concepts)\n   - [Rule](#rule)\n   - [Helper](#helper)\n     - [SonarQube Helper](#sonarqube-helper)\n     - [LLM Helper](#llm-helper)\n\n---\n\n## Features\n\n- **Multi-language support**: Analyze and refactor code across multiple programming languages.\n- **Rule-based engine**: Define custom rules for code analysis and remediation.\n- **Automated fixes**: Automatically apply fixes to detected violations.\n- **Extensible helpers**: Integrate with external systems like SonarQube or LLMs.\n\n---\n\n## Installation\n\n### From Playground\n\nTo load the Moose-Rule-Engine from the Playground, run the following script:\n\n```st\nMetacello new\n  githubUser: 'Evref-BL' project: 'Moose-Rule-Engine' commitish: 'main' path: 'src';\n  baseline: 'MooseRuleEngine';\n  onConflict: [ :ex | ex useIncoming ];\n  load.\n```\n\n### Baseline Dependency\n\nTo include Moose-Rule-Engine as a dependency in your project, add the following to your baseline:\n\n```st\nspec baseline: 'MooseRuleEngine' with: [\n  spec repository: 'github://Evref-BL/Moose-Rule-Engine:main'.\n].\n```\n\n---\n\n## Usage\n\nMooseRuleEngine take files and rules and return a collection of fixes. Here is a step by step on how to use it\n\n### 1. Initialize the Rule Engine\n\nStart by creating an instance of the `MooseRuleEngine`:\n\n```st\nruleEngine := MooseRuleEngine new.\n```\n\n### 2. Set Up Files\n\nYou need to provide the files you want to analyze. Create a file object and add it to the engine:\n\n```st\nfile := File new path: '\u003cpath/to/your/file\u003e'; content: '\u003cfile content\u003e'; model: '\u003cmodel moose of your file\u003e'.\n\nruleEngine setFiles: { file }.\n```\n### Optional: Set a Project Model\n\nYou can optionally define a model that represents your project, such as a Famix model. This model will be injected into all your rules, providing additional context for analysis and fixes:\n\n```st\nruleEngine setModel: model.\n```\n\n### 3. Define Rules\n\nDefine the rules you want to apply. Rules are objects that analyze files and suggest fixes. Add your rules to the engine:\n\n```st\nrule := MyCustomRule new.\nruleEngine setRules: { rule }.\n```\n\n### 4. Add Helpers (Optional)\n\nHelpers can be used to enhance the functionality of your rules. For example, you can add a SonarQube helper:\n\n```st\nsonarqubeApi := SonarQubeApi new host: '\u003cyour_sonarqube_host\u003e'; privateToken: '\u003cyour_private_token\u003e'.\nsonarHelper := MRESonarqubeHelper new \n  sonarqubeApi: sonarqubeApi;\n  projectKey: 'your_project_key';\n  type: 'all'.\n\nruleEngine addHelper: sonarHelper.\n```\n\n### 5. Run the Engine\n\nRun the engine to detect and fix issues in the provided files:\n\n```st\nfixes := ruleEngine detectAndFix.\n```\n\n### 6. Review the Output\n\nThe engine returns a collection of fixes. Each fix contains the following attributes:\n- **startPos**: Start position of the fix.\n- **endPos**: End position of the fix.\n- **content**: New content between start and end position\n- **file**: File where the fix is applied.\n\n\n## Core Concepts\n\n### Rule\n\nRules are the core of the Moose-Rule-Engine. A rule has:\n- **Name**: A unique identifier.\n- **Description**: A brief explanation of the rule.\n\n#### Example Initialization\n\n```st\ninitialize\n  super initialize.\n  name := 'name'.\n  description := 'description'.\n```\n\n#### Methods\n\n- `analyse`: Takes an `MREFile` and returns a collection of `MREViolation`.\n- `fix`: Takes an `MREViolation` and returns a collection of `MREFix`.\n\n### Helper\n\nHelpers are classes injected into rules to assist in writing them. They are useful for interacting with external systems like SonarQube or LLMs.\n\n#### Creating a Helper\n\nTo create a helper, extend `MREHelper` and define a name.\n\n#### Accessing a Helper in a Rule\n\n```st\nrule getHelper: 'helperName'.\n```\n\n#### SonarQube Helper\n\nThe SonarQube helper allows you to use SonarQube analysis in your rules.\n\n##### Example Usage\n\n```st\nsonarHelper violationsOf: rule inFile: file usingRuleId: sonarRuleId.\n```\n\n##### Initialization\n\n```st\nsonarqubeApi := SonarQubeApi new host: '\u003cyour_sonarqube_host\u003e'; privateToken: '\u003cyour_private_token\u003e'.\n\nsonarHelper := MRESonarqubeHelper new \n  sonarqubeApi: sonarqubeApi;\n  projectKey: 'your_project_key';\n  type: 'all'.\n```\n\n#### LLM Helper\n\nThe LLM helper can fix violations using a language model.\n\n##### Example Usage\n\n```st\nllmHelper fix: code withMessage: message.\n```\n\n##### Initialization\n\n```st\nllmApi := LLMAPI chat.\nllmApi host: '\u003cllm_host\u003e'.\nllmApi apiKey: '\u003cllm_api_key\u003e'.\nllmHelper := MRELLMHelper new llmApi: llmApi.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevref-bl%2Fmoose-rule-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevref-bl%2Fmoose-rule-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevref-bl%2Fmoose-rule-engine/lists"}