ruby-maat 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.commitlintrc.json +44 -0
  3. data/.mailmap +3 -0
  4. data/.overcommit.yml +77 -0
  5. data/.release-please-config.json +33 -0
  6. data/.release-please-manifest.json +3 -0
  7. data/.rspec +3 -0
  8. data/.rubocop.yml +48 -0
  9. data/CHANGELOG.md +46 -0
  10. data/CI_CD_SETUP.md +180 -0
  11. data/CLAUDE.md +130 -0
  12. data/Dockerfile +40 -0
  13. data/README.md +444 -0
  14. data/README_RUBY.md +300 -0
  15. data/RELEASE_PLEASE_SETUP.md +198 -0
  16. data/RUBY_MAAT.md +227 -0
  17. data/Rakefile +12 -0
  18. data/doc/imgs/abs_churn_sample.png +0 -0
  19. data/doc/imgs/code_age_sample.png +0 -0
  20. data/doc/imgs/coupling_sample.png +0 -0
  21. data/doc/imgs/crime_cover.jpg +0 -0
  22. data/doc/imgs/tree_map_sample.png +0 -0
  23. data/doc/intro.md +3 -0
  24. data/exe/ruby-maat +6 -0
  25. data/lib/ruby_maat/analysis/authors.rb +47 -0
  26. data/lib/ruby_maat/analysis/base_analysis.rb +70 -0
  27. data/lib/ruby_maat/analysis/churn.rb +255 -0
  28. data/lib/ruby_maat/analysis/code_age.rb +53 -0
  29. data/lib/ruby_maat/analysis/commit_messages.rb +58 -0
  30. data/lib/ruby_maat/analysis/communication.rb +56 -0
  31. data/lib/ruby_maat/analysis/effort.rb +150 -0
  32. data/lib/ruby_maat/analysis/entities.rb +40 -0
  33. data/lib/ruby_maat/analysis/identity.rb +12 -0
  34. data/lib/ruby_maat/analysis/logical_coupling.rb +134 -0
  35. data/lib/ruby_maat/analysis/sum_of_coupling.rb +43 -0
  36. data/lib/ruby_maat/analysis/summary.rb +43 -0
  37. data/lib/ruby_maat/app.rb +143 -0
  38. data/lib/ruby_maat/change_record.rb +47 -0
  39. data/lib/ruby_maat/cli.rb +187 -0
  40. data/lib/ruby_maat/dataset.rb +205 -0
  41. data/lib/ruby_maat/groupers/layer_grouper.rb +67 -0
  42. data/lib/ruby_maat/groupers/team_mapper.rb +51 -0
  43. data/lib/ruby_maat/groupers/time_grouper.rb +70 -0
  44. data/lib/ruby_maat/output/csv_output.rb +65 -0
  45. data/lib/ruby_maat/parsers/base_parser.rb +63 -0
  46. data/lib/ruby_maat/parsers/git2_parser.rb +72 -0
  47. data/lib/ruby_maat/parsers/git_parser.rb +66 -0
  48. data/lib/ruby_maat/parsers/mercurial_parser.rb +64 -0
  49. data/lib/ruby_maat/parsers/perforce_parser.rb +77 -0
  50. data/lib/ruby_maat/parsers/svn_parser.rb +76 -0
  51. data/lib/ruby_maat/parsers/tfs_parser.rb +103 -0
  52. data/lib/ruby_maat/version.rb +5 -0
  53. data/lib/ruby_maat.rb +44 -0
  54. metadata +143 -0
data/README_RUBY.md ADDED
@@ -0,0 +1,300 @@
1
+ # Ruby Maat
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/ruby-maat.svg)](https://badge.fury.io/rb/ruby-maat)
4
+ [![Build Status](https://github.com/viamin/ruby-maat/workflows/CI/badge.svg)](https://github.com/viamin/ruby-maat/actions)
5
+
6
+ Ruby Maat is a command line tool used to mine and analyze data from version-control systems (VCS). It's a Ruby port of the original [Code Maat](https://github.com/adamtornhill/code-maat) by Adam Tornhill.
7
+
8
+ Ruby Maat was developed to accompany the discussions in the books [Your Code as a Crime Scene](https://pragprog.com/titles/atcrime/your-code-as-a-crime-scene) and [Software Design X-Rays](https://pragprog.com/titles/atevol/software-design-x-rays).
9
+
10
+ **Note:** The analyses have evolved into [CodeScene](https://codescene.io/), which automates all the analyses found in Ruby Maat and several new ones.
11
+
12
+ ## Drop-in Replacement
13
+
14
+ Ruby Maat is designed as a **drop-in replacement** for Code Maat. It supports:
15
+
16
+ - ✅ Identical command-line arguments
17
+ - ✅ Same VCS log file formats
18
+ - ✅ Compatible CSV output format
19
+ - ✅ All original analysis types
20
+
21
+ Simply replace `java -jar code-maat.jar` with `ruby-maat` in your existing scripts!
22
+
23
+ ## Installation
24
+
25
+ ### Via RubyGems (Recommended)
26
+
27
+ ```bash
28
+ gem install ruby-maat
29
+ ```
30
+
31
+ ### From Source
32
+
33
+ ```bash
34
+ git clone https://github.com/viamin/ruby-maat.git
35
+ cd ruby-maat
36
+ bundle install
37
+ rake install
38
+ ```
39
+
40
+ ### Requirements
41
+
42
+ - Ruby 3.2 or later
43
+ - No external dependencies beyond the gem requirements
44
+
45
+ ## Usage
46
+
47
+ ### Basic Usage
48
+
49
+ ```bash
50
+ # Analyze Git repository
51
+ ruby-maat -l logfile.log -c git2 -a summary
52
+
53
+ # With specific analysis
54
+ ruby-maat -l logfile.log -c git2 -a coupling
55
+
56
+ # Write to file
57
+ ruby-maat -l logfile.log -c git2 -a authors -o results.csv
58
+ ```
59
+
60
+ ### Command Line Options
61
+
62
+ ```
63
+ Usage: ruby-maat -l log-file -c vcs-type [options]
64
+
65
+ Required:
66
+ -l, --log LOG Log file with input data
67
+ -c, --version-control VCS Input vcs module type: supports svn, git, git2, hg, p4, or tfs
68
+
69
+ Analysis:
70
+ -a, --analysis ANALYSIS The analysis to run (default: authors)
71
+ Available: abs-churn, age, author-churn, authors, communication,
72
+ coupling, entity-churn, entity-effort, entity-ownership,
73
+ fragmentation, identity, main-dev, main-dev-by-revs, messages,
74
+ refactoring-main-dev, revisions, soc, summary
75
+
76
+ Output:
77
+ -r, --rows ROWS Max rows in output
78
+ -o, --outfile OUTFILE Write the result to the given file name
79
+ --input-encoding ENCODING Specify an encoding other than UTF-8 for the log file
80
+
81
+ Grouping:
82
+ -g, --group GROUP A file with a pre-defined set of layers
83
+ -p, --team-map-file TEAM_MAP A CSV file with author,team mappings
84
+ -t, --temporal-period PERIOD Group commits by temporal period
85
+
86
+ Filtering:
87
+ -n, --min-revs MIN_REVS Minimum number of revisions (default: 5)
88
+ -m, --min-shared-revs MIN_SHARED Minimum shared revisions (default: 5)
89
+ -i, --min-coupling MIN_COUPLING Minimum coupling percentage (default: 30)
90
+ -x, --max-coupling MAX_COUPLING Maximum coupling percentage (default: 100)
91
+ -s, --max-changeset-size SIZE Maximum changeset size (default: 30)
92
+
93
+ Analysis-specific:
94
+ -e, --expression-to-match REGEX Regex for commit message analysis
95
+ -d, --age-time-now DATE Reference date for age analysis (YYYY-MM-dd)
96
+ --verbose-results Include additional analysis details
97
+
98
+ Other:
99
+ -h, --help Show this help message
100
+ --version Show version information
101
+ ```
102
+
103
+ ## Generating Input Data
104
+
105
+ Ruby Maat operates on log files from version-control systems. **Use the exact same commands as Code Maat:**
106
+
107
+ ### Git (Recommended: git2 format)
108
+
109
+ ```bash
110
+ git log --all --numstat --date=short --pretty=format:'--%h--%ad--%aN' --no-renames --after=YYYY-MM-DD > logfile.log
111
+ ```
112
+
113
+ Then use `-c git2` when running Ruby Maat.
114
+
115
+ ### Git (Legacy format)
116
+
117
+ ```bash
118
+ git log --pretty=format:'[%h] %aN %ad %s' --date=short --numstat --after=YYYY-MM-DD > logfile.log
119
+ ```
120
+
121
+ Then use `-c git` when running Ruby Maat.
122
+
123
+ ### Subversion
124
+
125
+ ```bash
126
+ svn log -v --xml > logfile.log -r {YYYYmmDD}:HEAD
127
+ ```
128
+
129
+ ### Other VCS Systems
130
+
131
+ Ruby Maat supports the same log formats as Code Maat for:
132
+
133
+ - Mercurial (`hg`)
134
+ - Perforce (`p4`)
135
+ - Team Foundation Server (`tfs`)
136
+
137
+ See the [original documentation](https://github.com/adamtornhill/code-maat#generating-input-data) for specific commands.
138
+
139
+ ## Available Analyses
140
+
141
+ | Analysis | Description |
142
+ |----------|-------------|
143
+ | `authors` | Number of authors per module (default) |
144
+ | `revisions` | Number of revisions per entity |
145
+ | `coupling` | Logical coupling between modules |
146
+ | `soc` | Sum of coupling per entity |
147
+ | `summary` | High-level project statistics |
148
+ | `abs-churn` | Absolute code churn over time |
149
+ | `author-churn` | Code churn per author |
150
+ | `entity-churn` | Code churn per entity |
151
+ | `entity-ownership` | Code ownership per author per entity |
152
+ | `main-dev` | Main developer per entity (by lines) |
153
+ | `main-dev-by-revs` | Main developer per entity (by commits) |
154
+ | `entity-effort` | Development effort per author per entity |
155
+ | `fragmentation` | Ownership fragmentation (fractal value) |
156
+ | `communication` | Developer communication patterns |
157
+ | `age` | Code age analysis |
158
+ | `messages` | Commit message word frequency |
159
+ | `identity` | Raw data dump (debugging) |
160
+
161
+ ## Examples
162
+
163
+ ### Authors Analysis
164
+
165
+ ```bash
166
+ ruby-maat -l git.log -c git2 -a authors
167
+ ```
168
+
169
+ Output:
170
+
171
+ ```csv
172
+ entity,n-authors,n-revs
173
+ InfoUtils.java,12,60
174
+ BarChart.java,7,30
175
+ Page.java,4,27
176
+ ```
177
+
178
+ ### Logical Coupling
179
+
180
+ ```bash
181
+ ruby-maat -l git.log -c git2 -a coupling
182
+ ```
183
+
184
+ Output:
185
+
186
+ ```csv
187
+ entity,coupled,degree,average-revs
188
+ InfoUtils.java,Page.java,78,44
189
+ InfoUtils.java,BarChart.java,62,45
190
+ ```
191
+
192
+ ### Summary Statistics
193
+
194
+ ```bash
195
+ ruby-maat -l git.log -c git2 -a summary
196
+ ```
197
+
198
+ Output:
199
+
200
+ ```csv
201
+ statistic,value
202
+ number-of-commits,919
203
+ number-of-entities,730
204
+ number-of-entities-changed,3397
205
+ number-of-authors,79
206
+ ```
207
+
208
+ ## Advanced Features
209
+
210
+ ### Architectural Grouping
211
+
212
+ Group files into architectural layers:
213
+
214
+ ```
215
+ # layers.txt
216
+ src/Features/Core => Core
217
+ ^src\/.*\/.*Tests\.cs$ => CS Tests
218
+ ```
219
+
220
+ ```bash
221
+ ruby-maat -l git.log -c git2 -a coupling -g layers.txt
222
+ ```
223
+
224
+ ### Team Analysis
225
+
226
+ Map individual authors to teams:
227
+
228
+ ```csv
229
+ # teams.csv
230
+ author,team
231
+ john.doe,Backend Team
232
+ jane.smith,Frontend Team
233
+ ```
234
+
235
+ ```bash
236
+ ruby-maat -l git.log -c git2 -a authors -p teams.csv
237
+ ```
238
+
239
+ ### Temporal Analysis
240
+
241
+ Group commits by time period:
242
+
243
+ ```bash
244
+ ruby-maat -l git.log -c git2 -a coupling -t day
245
+ ```
246
+
247
+ ## Differences from Code Maat
248
+
249
+ While Ruby Maat is a drop-in replacement, there are some minor differences:
250
+
251
+ ### Advantages
252
+
253
+ - **Faster startup**: No JVM startup time
254
+ - **Better memory efficiency**: Ruby's garbage collection
255
+ - **Easier installation**: No Java dependencies
256
+ - **Native Ruby integration**: Use as a library in Ruby projects
257
+
258
+ ### Performance
259
+
260
+ - Ruby Maat may be slightly slower on very large datasets
261
+ - For most repositories, performance is comparable
262
+ - Memory usage is typically lower than the JVM version
263
+
264
+ ## Development
265
+
266
+ ### Running Tests
267
+
268
+ ```bash
269
+ bundle install
270
+ bundle exec rspec
271
+ ```
272
+
273
+ ### Code Quality
274
+
275
+ ```bash
276
+ bundle exec rubocop
277
+ ```
278
+
279
+ ### Building the Gem
280
+
281
+ ```bash
282
+ bundle exec rake build
283
+ ```
284
+
285
+ ## Contributing
286
+
287
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/viamin/ruby-maat>.
288
+
289
+ ## License
290
+
291
+ Ruby Maat is distributed under the [GNU General Public License v3.0](http://www.gnu.org/licenses/gpl.html), the same license as the original Code Maat.
292
+
293
+ ## Acknowledgments
294
+
295
+ - **Adam Tornhill** - Original Code Maat author and creator of the analysis algorithms
296
+ - **Code Maat contributors** - For the foundational work this port is based on
297
+
298
+ ## About the Name
299
+
300
+ Like the original Code Maat, this tool is named after Maat, the ancient Egyptian goddess of truth, justice, and order. Ruby Maat continues Maat's work of bringing order to chaotic codebases, now in Ruby.
@@ -0,0 +1,198 @@
1
+ # Release Please Setup
2
+
3
+ This document explains how the automated release system works using Google's Release Please.
4
+
5
+ ## Overview
6
+
7
+ Release Please automates:
8
+
9
+ - ✅ **Version bumping** based on conventional commits
10
+ - ✅ **CHANGELOG generation** from commit messages
11
+ - ✅ **Release creation** with proper Git tags
12
+ - ✅ **Gem publishing** to RubyGems.org
13
+ - ✅ **GitHub release** with artifacts
14
+
15
+ ## How It Works
16
+
17
+ ### 1. Conventional Commits
18
+
19
+ Developers use conventional commit format:
20
+
21
+ ```bash
22
+ git commit -m "feat(parser): add SVN log support"
23
+ git commit -m "fix(analysis): handle empty datasets correctly"
24
+ git commit -m "docs: update CLI examples"
25
+ ```
26
+
27
+ ### 2. Release Please Analysis
28
+
29
+ On every push to main/master:
30
+
31
+ - Analyzes commits since last release
32
+ - Determines if a release is needed
33
+ - Calculates version bump (patch/minor/major)
34
+
35
+ ### 3. Release PR Creation
36
+
37
+ When releasable changes exist:
38
+
39
+ - Creates/updates a "Release PR"
40
+ - Updates version files
41
+ - Generates/updates CHANGELOG.md
42
+ - Ready for review and approval
43
+
44
+ ### 4. Automated Publishing
45
+
46
+ When Release PR is merged:
47
+
48
+ - Creates GitHub release with tag
49
+ - Publishes gem to RubyGems.org
50
+ - Uploads gem artifact to release
51
+
52
+ ## Configuration Files
53
+
54
+ ### `.release-please-config.json`
55
+
56
+ - Package configuration
57
+ - Version file locations
58
+ - Changelog sections
59
+ - Extra files to update
60
+
61
+ ### `.release-please-manifest.json`
62
+
63
+ - Tracks current version
64
+ - Updated automatically by Release Please
65
+
66
+ ### `.commitlintrc.json`
67
+
68
+ - Validates conventional commit format
69
+ - Enforces consistent commit messages
70
+ - Runs on pull requests
71
+
72
+ ### `.gitmessage`
73
+
74
+ - Commit message template
75
+ - Set up with: `git config commit.template .gitmessage`
76
+
77
+ ## Conventional Commit Types
78
+
79
+ | Type | Description | Version Bump |
80
+ |------|-------------|--------------|
81
+ | `feat:` | New feature | Minor |
82
+ | `fix:` | Bug fix | Patch |
83
+ | `feat!:` | Breaking change | Major |
84
+ | `BREAKING CHANGE:` | Breaking change | Major |
85
+ | `docs:` | Documentation | None |
86
+ | `style:` | Code style | None |
87
+ | `refactor:` | Code refactoring | None |
88
+ | `test:` | Tests | None |
89
+ | `chore:` | Maintenance | None |
90
+ | `ci:` | CI/CD changes | None |
91
+ | `deps:` | Dependencies | None |
92
+
93
+ ## Common Scopes
94
+
95
+ - `analysis` - Analysis modules
96
+ - `parser` - VCS parsers
97
+ - `output` - Output formatters
98
+ - `cli` - Command-line interface
99
+ - `dataset` - Data handling
100
+ - `core` - Core functionality
101
+
102
+ ## Example Workflow
103
+
104
+ 1. **Feature Development**:
105
+
106
+ ```bash
107
+ git commit -m "feat(analysis): add complexity metrics analysis"
108
+ git commit -m "test(analysis): add tests for complexity metrics"
109
+ git commit -m "docs(analysis): document complexity analysis options"
110
+ ```
111
+
112
+ 2. **Push to Main**:
113
+
114
+ ```bash
115
+ git push origin main
116
+ ```
117
+
118
+ 3. **Release Please Actions**:
119
+ - Analyzes commits
120
+ - Creates Release PR titled "chore(main): release 1.1.0"
121
+ - Updates version from 1.0.0 → 1.1.0
122
+ - Adds feature to CHANGELOG.md
123
+
124
+ 4. **Review & Merge**:
125
+ - Review the generated changelog
126
+ - Merge the Release PR
127
+ - Automatic publishing begins
128
+
129
+ 5. **Published Release**:
130
+ - GitHub release created with tag v1.1.0
131
+ - Gem published to RubyGems.org
132
+ - Gem artifact attached to release
133
+
134
+ ## Benefits Over Manual Releases
135
+
136
+ - ✅ **No version conflicts** - automated version management
137
+ - ✅ **Consistent changelogs** - generated from commits
138
+ - ✅ **Enforced conventions** - conventional commit validation
139
+ - ✅ **Zero-downtime releases** - automated testing before publish
140
+ - ✅ **Release approval** - review before publishing via Release PR
141
+ - ✅ **Atomic releases** - all-or-nothing publishing
142
+
143
+ ## Troubleshooting
144
+
145
+ ### No Release PR Created
146
+
147
+ - Check if commits follow conventional format
148
+ - Ensure commits contain releasable changes (`feat:`, `fix:`, etc.)
149
+ - Verify `.release-please-config.json` is valid
150
+
151
+ ### Release PR Not Publishing
152
+
153
+ - Check RubyGems API key secret is set
154
+ - Verify tests pass in CI
155
+ - Ensure gem version isn't already published
156
+
157
+ ### Version Not Updated
158
+
159
+ - Check `version-file` path in config
160
+ - Verify `extra-files` configuration for gemspec
161
+ - Ensure Release PR was merged, not just closed
162
+
163
+ ## Manual Override
164
+
165
+ To create a release manually:
166
+
167
+ ```bash
168
+ # Trigger release-please workflow manually
169
+ gh workflow run publish.yml
170
+
171
+ # Or create a conventional commit that forces a release
172
+ git commit -m "chore: trigger release" --allow-empty
173
+ git push origin main
174
+ ```
175
+
176
+ ## Getting Started
177
+
178
+ 1. **Set up commit template**:
179
+
180
+ ```bash
181
+ git config commit.template .gitmessage
182
+ ```
183
+
184
+ 2. **Use conventional commits**:
185
+
186
+ ```bash
187
+ git commit -m "feat(cli): add new --format option"
188
+ ```
189
+
190
+ 3. **Push changes**:
191
+
192
+ ```bash
193
+ git push origin main
194
+ ```
195
+
196
+ 4. **Wait for Release PR** and review/merge when ready
197
+
198
+ That's it! The rest is automated. 🚀
data/RUBY_MAAT.md ADDED
@@ -0,0 +1,227 @@
1
+ # RUBY_MAAT.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with the Ruby Maat codebase.
4
+
5
+ ## Project Overview
6
+
7
+ Ruby Maat is a Ruby port of Code Maat, maintaining full backward compatibility while providing a modern Ruby implementation. It's designed as a drop-in replacement for the original Clojure version.
8
+
9
+ ## Build and Development Commands
10
+
11
+ ### Setting Up Development Environment
12
+
13
+ ```bash
14
+ # Install dependencies
15
+ bundle install
16
+
17
+ # Run tests
18
+ bundle exec rspec
19
+
20
+ # Run linting
21
+ bundle exec rubocop
22
+
23
+ # Auto-fix linting issues
24
+ bundle exec rubocop -a
25
+
26
+ # Run all checks
27
+ bundle exec rake
28
+ ```
29
+
30
+ ### Building and Installing
31
+
32
+ ```bash
33
+ # Build gem
34
+ bundle exec rake build
35
+
36
+ # Install locally
37
+ bundle exec rake install
38
+
39
+ # Run the CLI locally
40
+ bundle exec exe/ruby-maat --help
41
+ ```
42
+
43
+ ### Testing
44
+
45
+ ```bash
46
+ # Run all tests
47
+ bundle exec rspec
48
+
49
+ # Run specific test file
50
+ bundle exec rspec spec/ruby_maat/analysis/authors_spec.rb
51
+
52
+ # Run with coverage
53
+ bundle exec rspec --format documentation
54
+
55
+ # Test specific functionality
56
+ bundle exec rspec --tag focus
57
+ ```
58
+
59
+ ## Architecture Overview
60
+
61
+ ### Core Components
62
+
63
+ 1. **Command Line Interface** (`lib/ruby_maat/cli.rb`)
64
+ - Uses optparse for argument parsing
65
+ - Maintains full backward compatibility with Code Maat CLI
66
+ - Provides identical command-line arguments and behavior
67
+
68
+ 2. **Application Core** (`lib/ruby_maat/app.rb`)
69
+ - Main orchestration following same pipeline as original:
70
+ - VCS Parsing → Data Grouping → Analysis → CSV Output
71
+ - Registry pattern for analysis selection
72
+ - Error handling and recovery
73
+
74
+ 3. **Data Model**
75
+ - `ChangeRecord` - Immutable value object for VCS changes
76
+ - `Dataset` - Wrapper around Rover DataFrame for domain operations
77
+ - Clean separation between data structures and business logic
78
+
79
+ 4. **VCS Parsers** (`lib/ruby_maat/parsers/`)
80
+ - Strategy pattern with base class and specific implementations
81
+ - Identical input formats as original Code Maat
82
+ - Error handling for malformed log files
83
+
84
+ 5. **Analysis Modules** (`lib/ruby_maat/analysis/`)
85
+ - Object-oriented design with base class and inheritance
86
+ - Each analysis encapsulates domain logic
87
+ - Rover DataFrame integration for statistical operations
88
+
89
+ 6. **Data Processors** (`lib/ruby_maat/groupers/`)
90
+ - Layer grouping for architectural boundaries
91
+ - Temporal grouping for time-based analysis
92
+ - Team mapping for organizational analysis
93
+
94
+ ### Key Design Decisions
95
+
96
+ **Rover DataFrame Integration:**
97
+
98
+ - Replaces Incanter from original Clojure version
99
+ - Provides statistical computing capabilities
100
+ - Andrew Kane's excellent DataFrame library
101
+
102
+ **Object-Oriented Architecture:**
103
+
104
+ - Functional Clojure code translated to Ruby OOP
105
+ - Strategy pattern for parsers and analyses
106
+ - Immutable value objects where appropriate
107
+
108
+ **Backward Compatibility:**
109
+
110
+ - Identical CLI arguments and behavior
111
+ - Same CSV output format
112
+ - Compatible with existing scripts and workflows
113
+
114
+ ### Analysis Modules
115
+
116
+ All analyses inherit from `BaseAnalysis` and implement `analyze(dataset, options)`:
117
+
118
+ **Core Analyses:**
119
+
120
+ - `Authors` - Developer count and revision metrics per entity
121
+ - `LogicalCoupling` - Entities that change together
122
+ - `Entities` - Basic revision counts
123
+ - `Summary` - High-level repository statistics
124
+
125
+ **Code Quality Analyses:**
126
+
127
+ - `Churn::*` - Various code churn metrics
128
+ - `Effort::*` - Developer effort and ownership patterns
129
+ - `CodeAge` - Time since last modification
130
+ - `SumOfCoupling` - Aggregated coupling metrics
131
+
132
+ **Social Analyses:**
133
+
134
+ - `Communication` - Developer collaboration patterns
135
+ - `CommitMessages` - Commit message word frequency
136
+
137
+ ### Data Flow
138
+
139
+ 1. **Parse** - VCS log files → Array of `ChangeRecord` objects
140
+ 2. **Group** - Apply architectural/temporal/team grouping transformations
141
+ 3. **Analyze** - Convert to `Dataset` and run analysis algorithms
142
+ 4. **Output** - Format results as CSV using `CsvOutput`
143
+
144
+ ### Ruby-Specific Patterns
145
+
146
+ **Enumerable Usage:**
147
+
148
+ - Heavy use of `map`, `filter`, `group_by`, `sort_by`
149
+ - Functional programming style within OOP structure
150
+
151
+ **Error Handling:**
152
+
153
+ - Consistent error messages and recovery
154
+ - Validation at boundaries (CLI, file parsing)
155
+ - Meaningful error messages for users
156
+
157
+ **Memory Efficiency:**
158
+
159
+ - Streaming CSV output
160
+ - Efficient data structures
161
+ - Garbage collection friendly
162
+
163
+ ## Testing Strategy
164
+
165
+ **RSpec Structure:**
166
+
167
+ - Unit tests for each class and module
168
+ - Integration tests for end-to-end workflows
169
+ - Test data using `ChangeRecord` factories
170
+
171
+ **Key Test Areas:**
172
+
173
+ - Parser accuracy for all VCS formats
174
+ - Analysis algorithm correctness
175
+ - CLI argument parsing and validation
176
+ - Error handling and edge cases
177
+
178
+ **Test Data:**
179
+
180
+ - Small, focused datasets for unit tests
181
+ - Real-world patterns for integration tests
182
+ - Edge cases (empty files, malformed data, etc.)
183
+
184
+ ## Development Guidelines
185
+
186
+ **Code Style:**
187
+
188
+ - Follow Ruby community conventions
189
+ - Use RuboCop for consistency
190
+ - Prefer explicit over implicit
191
+ - Clear method and variable names
192
+
193
+ **Performance:**
194
+
195
+ - Profile with large datasets during development
196
+ - Memory-conscious data structures
197
+ - Efficient algorithms for coupling analysis
198
+
199
+ **Compatibility:**
200
+
201
+ - Maintain CLI compatibility religiously
202
+ - Test against Code Maat output for regression
203
+ - Document any behavioral differences
204
+
205
+ ## Integration with Original Code Maat
206
+
207
+ Ruby Maat is designed to be a seamless replacement:
208
+
209
+ **Input Compatibility:**
210
+
211
+ - Accepts identical VCS log file formats
212
+ - Same command-line arguments and flags
213
+ - Compatible option parsing and validation
214
+
215
+ **Output Compatibility:**
216
+
217
+ - Identical CSV column names and formats
218
+ - Same sorting and filtering behavior
219
+ - Matching precision for numerical results
220
+
221
+ **Feature Parity:**
222
+
223
+ - All 23 analysis types implemented
224
+ - Same grouping and mapping capabilities
225
+ - Identical error messages where possible
226
+
227
+ This makes Ruby Maat suitable for existing Code Maat workflows, scripts, and integrations without modification.