Skip to content

Commit 0e71b7d

Browse files
authored
Merge pull request #4 from Oltrematica/003-jira-quality-metrics
feat(jira): implement quality metrics for Jira issues (Feature 003)
2 parents 285f983 + c502cdf commit 0e71b7d

23 files changed

Lines changed: 4787 additions & 9 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Auto-generated from all feature plans. Last updated: 2025-11-28
55
## Active Technologies
66
- Python 3.9+ (per constitution, leveraging type hints) + Standard library (urllib, json, csv, os, re); optional: requests (002-jira-integration)
77
- CSV files for export (same as existing GitHub exports) (002-jira-integration)
8+
- Python 3.9+ (per constitution, leveraging type hints) + Standard library only (urllib, json, csv, os, re, datetime, statistics); optional: requests (already used in jira_client.py) (003-jira-quality-metrics)
89

910
- Python 3.9+ (as per constitution, leveraging type hints) + Standard library only (urllib, json, csv, os, re); optional: requests (001-modular-refactor)
1011

@@ -36,6 +37,7 @@ python github_analyzer.py --days 7
3637
Python 3.9+ (as per constitution, leveraging type hints): Follow standard conventions
3738

3839
## Recent Changes
40+
- 003-jira-quality-metrics: Added Python 3.9+ (per constitution, leveraging type hints) + Standard library only (urllib, json, csv, os, re, datetime, statistics); optional: requests (already used in jira_client.py)
3941
- 002-jira-integration: Added Python 3.9+ (per constitution, leveraging type hints) + Standard library (urllib, json, csv, os, re); optional: requests
4042

4143
- 001-modular-refactor: Added Python 3.9+ (as per constitution, leveraging type hints) + Standard library only (urllib, json, csv, os, re); optional: requests

README.md

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ A powerful Python command-line tool for analyzing GitHub repositories and Jira p
2020
- **Quality Metrics** - Assess code quality through revert ratios, review coverage, and commit message analysis
2121
- **Productivity Scoring** - Calculate composite productivity scores for contributors across repositories
2222

23-
### Jira Integration (NEW)
23+
### Jira Integration
2424
- **Jira Issue Extraction** - Extract issues and comments from Jira Cloud and Server/Data Center
25+
- **Quality Metrics** - Calculate 10 quality metrics per issue including cycle time, description quality, collaboration scores
26+
- **Aggregated Reports** - Generate project-level, person-level, and issue-type summaries
2527
- **Multi-Project Support** - Analyze multiple Jira projects with interactive project selection
2628
- **Time-Based Filtering** - Filter issues by update date using JQL queries
2729
- **Comment Tracking** - Export all issue comments with author and timestamp
30+
- **Reopen Tracking** - Detect reopened issues via changelog API (best-effort, graceful degradation)
2831
- **ADF Support** - Automatically converts Atlassian Document Format to plain text
2932

3033
### Core Features
@@ -222,12 +225,15 @@ The analyzer generates CSV files in the output directory. GitHub outputs are alw
222225
| `productivity_analysis.csv` | Per-contributor productivity metrics and scores |
223226
| `contributors_summary.csv` | Contributor overview with commit and PR statistics |
224227

225-
**Jira outputs (2 files):**
228+
**Jira outputs (5 files):**
226229

227230
| File | Description |
228231
|------|-------------|
229-
| `jira_issues_export.csv` | Jira issues with key, summary, status, type, priority, assignee, reporter, dates |
232+
| `jira_issues_export.csv` | Jira issues with 12 base fields + 10 quality metrics per issue |
230233
| `jira_comments_export.csv` | Jira issue comments with issue key, author, date, body |
234+
| `jira_project_metrics.csv` | Aggregated metrics per project (cycle time, bug ratio, quality scores) |
235+
| `jira_person_metrics.csv` | Per-assignee metrics (WIP count, resolved count, avg cycle time) |
236+
| `jira_type_metrics.csv` | Per-issue-type metrics (counts, avg cycle time, bug resolution time) |
231237

232238
### CSV Field Details
233239

@@ -267,9 +273,79 @@ first_activity, last_activity, active_days, consistency_pct,
267273
productivity_score
268274
```
269275

270-
## Quality Metrics Explained
276+
#### jira_issues_export.csv
277+
```
278+
key, summary, description, status, issue_type, priority, assignee, reporter,
279+
created, updated, resolution_date, project_key,
280+
cycle_time_days, aging_days, comments_count, description_quality_score,
281+
acceptance_criteria_present, comment_velocity_hours, silent_issue,
282+
same_day_resolution, cross_team_score, reopen_count
283+
```
284+
285+
#### jira_project_metrics.csv
286+
```
287+
project_key, total_issues, resolved_count, unresolved_count,
288+
avg_cycle_time_days, median_cycle_time_days, bug_count, bug_ratio_percent,
289+
same_day_resolution_rate_percent, avg_description_quality,
290+
silent_issues_ratio_percent, avg_comments_per_issue,
291+
avg_comment_velocity_hours, reopen_rate_percent
292+
```
293+
294+
#### jira_person_metrics.csv
295+
```
296+
assignee_name, wip_count, resolved_count, total_assigned,
297+
avg_cycle_time_days, bug_count_assigned
298+
```
299+
300+
#### jira_type_metrics.csv
301+
```
302+
issue_type, count, resolved_count, avg_cycle_time_days,
303+
bug_resolution_time_avg
304+
```
271305

272-
The analyzer calculates several quality indicators:
306+
## Jira Quality Metrics Explained
307+
308+
The analyzer calculates 10 quality metrics for each Jira issue:
309+
310+
| Metric | Description | Value |
311+
|--------|-------------|-------|
312+
| **cycle_time_days** | Days from created to resolution | Float (empty if open) |
313+
| **aging_days** | Days since creation for open issues | Float (empty if resolved) |
314+
| **comments_count** | Total number of comments | Integer |
315+
| **description_quality_score** | Quality score based on length, AC, formatting | 0-100 |
316+
| **acceptance_criteria_present** | AC patterns detected (Given/When/Then, checkboxes) | true/false |
317+
| **comment_velocity_hours** | Hours from creation to first comment | Float (empty if silent) |
318+
| **silent_issue** | No comments exist | true/false |
319+
| **same_day_resolution** | Resolved on same day as created | true/false |
320+
| **cross_team_score** | Collaboration score based on distinct commenters | 0-100 |
321+
| **reopen_count** | Times reopened (Done→non-Done transitions) | Integer |
322+
323+
### Description Quality Score Calculation
324+
325+
The quality score (0-100) uses balanced weighting:
326+
327+
| Component | Weight | Criteria |
328+
|-----------|--------|----------|
329+
| **Length** | 40% | Linear scale: 100+ chars = full score |
330+
| **Acceptance Criteria** | 40% | Detected patterns: Given/When/Then, AC:, checkboxes |
331+
| **Formatting** | 20% | Headers (10%) + Lists (10%) detected |
332+
333+
### Cross-Team Collaboration Score
334+
335+
Based on distinct comment authors:
336+
337+
| Authors | Score |
338+
|---------|-------|
339+
| 0 | 0 |
340+
| 1 | 25 |
341+
| 2 | 50 |
342+
| 3 | 75 |
343+
| 4 | 90 |
344+
| 5+ | 100 |
345+
346+
## GitHub Quality Metrics Explained
347+
348+
The analyzer calculates several quality indicators for GitHub repositories:
273349

274350
| Metric | Description | Ideal |
275351
|--------|-------------|-------|
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Requirements Quality Checklist: Jira Quality Metrics Export
2+
3+
**Purpose**: Comprehensive requirements quality validation for PR review
4+
**Created**: 2025-11-28
5+
**Feature**: [spec.md](../spec.md)
6+
**Depth**: Standard (PR Review)
7+
**Audience**: Reviewer
8+
9+
---
10+
11+
## Algorithm/Calculation Requirements
12+
13+
- [x] CHK001 - Is the linear interpolation for length score (0-100 chars → 0-40 points) explicitly defined? [Clarity, Spec §FR-004]
14+
- ✓ Defined in research.md §3: `length_score = min(40, int(length * 40 / 100))` and data-model.md §Configuration
15+
- [x] CHK002 - Are the exact regex patterns for acceptance criteria detection documented? [Completeness, Spec §FR-005]
16+
- ✓ Defined in research.md §2 and data-model.md §Configuration Constants: 5 AC_PATTERNS listed
17+
- [x] CHK003 - Is the diminishing scale for cross_team_score (1=25, 2=50, 3=75, 4=90, 5+=100) applied to 0 authors? [Gap, Spec §FR-009]
18+
- ✓ Defined in research.md §4: returns 0 for empty comments list
19+
- [x] CHK004 - Is "same day" for same_day_resolution defined in terms of timezone handling? [Ambiguity, Spec §FR-008]
20+
- ✓ Implicitly: comparison uses created and resolution_date which are ISO8601 with timezone (contracts/csv-schemas.md)
21+
- [x] CHK005 - Is the precision for cycle_time_days calculation specified (integer days vs fractional)? [Clarity, Spec §FR-001]
22+
- ✓ data-model.md: `cycle_time_days: float | None`; contracts: 2 decimal places
23+
- [x] CHK006 - Are the formatting detection patterns (headers/lists) for quality score explicitly listed? [Completeness, Spec §FR-004]
24+
- ✓ Defined in research.md §3: `r'^#+\s'` for headers, `r'^\s*[-*]\s'` for lists
25+
- [x] CHK007 - Is the calculation formula for avg_comment_velocity_hours specified (excludes silent issues)? [Clarity, Spec §FR-014]
26+
- ✓ data-model.md §ProjectMetrics: "Mean comment_velocity for non-silent issues"
27+
28+
---
29+
30+
## Data Model & Schema Requirements
31+
32+
- [x] CHK008 - Is the relationship between cycle_time_days and aging_days mutual exclusion clearly stated? [Consistency, Data Model]
33+
- ✓ data-model.md §IssueMetrics: "cycle_time_days: Days from created to resolution (None if unresolved)" and "aging_days: Days from created to now (None if resolved)"
34+
- [x] CHK009 - Are all 10 new CSV columns documented with exact data types and formats? [Completeness, Contracts §1]
35+
- ✓ contracts/csv-schemas.md §1 Schema table: all 10 columns with Type, Description, Example
36+
- [x] CHK010 - Is the handling of None/null values in CSV export explicitly defined (empty string vs "null")? [Clarity, Contracts §1 Notes]
37+
- ✓ contracts/csv-schemas.md §1 Notes: "Empty values: empty string (not `null` or `N/A`)"
38+
- [x] CHK011 - Are float precision requirements (2 decimal places) consistent across all metrics? [Consistency, Contracts]
39+
- ✓ contracts/csv-schemas.md §Validation Rules: "Floats: 2 decimal places, no thousands separator"
40+
- [x] CHK012 - Is the boolean format ("true"/"false" lowercase) requirement applied to all boolean fields? [Consistency, Contracts §1 Notes]
41+
- ✓ contracts/csv-schemas.md §1 Notes + §Validation Rules: "Booleans: `true` or `false` (lowercase)"
42+
- [x] CHK013 - Are PersonMetrics validation rules for empty assignee_name consistent with edge case handling? [Consistency, Data Model]
43+
- ✓ data-model.md §PersonMetrics: "assignee_name: Must not be empty string; issues without assignee are excluded" + spec.md §Edge Cases
44+
- [x] CHK014 - Is the constraint `wip_count + resolved_count = total_assigned` documented in both data model and spec? [Traceability, Data Model]
45+
- ✓ data-model.md §PersonMetrics Validation Rules: "`wip_count` + `resolved_count` = `total_assigned`"
46+
47+
---
48+
49+
## Edge Case & Error Handling Requirements
50+
51+
- [x] CHK015 - Is negative cycle_time handling (warning + null) behavior testable with specific criteria? [Measurability, Spec §Edge Cases]
52+
- ✓ spec.md §Edge Cases: "System logs a warning and sets cycle_time to null"; data-model.md §Validation: "negative values logged as warning and set to None"
53+
- [x] CHK016 - Are division-by-zero scenarios explicitly enumerated for all ratio calculations? [Coverage, Spec §Edge Cases]
54+
- ✓ spec.md §Edge Cases: "Return 0% or null with appropriate note"; data-model.md §ProjectMetrics: "Division by zero: Return 0.0 for ratios, None for averages"
55+
- [x] CHK017 - Is the behavior for issues with resolution_date but no created date defined? [Gap]
56+
- ✓ spec.md §Assumptions: "Creation and resolution dates are always present and valid for resolved issues" - invalid data is out of scope
57+
- [x] CHK018 - Are requirements for handling malformed ADF descriptions specified? [Gap, Spec §Edge Cases]
58+
- ✓ spec.md §Edge Cases: "How is description quality score calculated for ADF format descriptions? → Convert to plain text first, then analyze"
59+
- [x] CHK019 - Is the fallback behavior when changelog API returns 403/404 documented? [Completeness, Spec §Assumptions]
60+
- ✓ research.md §1: "If API returns 403 (permissions) or 404, reopen_count defaults to 0 without error"; tasks.md T040 tests this
61+
- [x] CHK020 - Are requirements defined for issues with future dates (created > now)? [Gap, Edge Case]
62+
- ✓ Handled by CHK015 - negative cycle_time results in warning + null; aging_days would be negative → same treatment
63+
- [x] CHK021 - Is handling of issues re-assigned during analysis period specified for PersonMetrics? [Gap]
64+
- ✓ Implicitly: PersonMetrics aggregates by current assignee field value at export time (snapshot-based, not historical)
65+
66+
---
67+
68+
## API Integration Requirements
69+
70+
- [x] CHK022 - Is the Jira changelog API endpoint path explicitly documented for v2 and v3? [Completeness, Gap]
71+
- ✓ research.md §1: "GET /rest/api/{version}/issue/{issueKey}/changelog" - version parameterized
72+
- [x] CHK023 - Are retry/timeout requirements for changelog API calls specified? [Gap]
73+
- ✓ Inherits from constitution §API Client Standards: "configurable timeouts (default: 30s)", "exponential backoff for transient failures"
74+
- [x] CHK024 - Is the "Done" status list (Done, Closed, Resolved, Complete, Completed) configurable or hardcoded? [Clarity, Data Model §Configuration]
75+
- ✓ data-model.md §Configuration Constants: `DONE_STATUSES = {'Done', 'Closed', 'Resolved', 'Complete', 'Completed'}` - constant (config changeable)
76+
- [x] CHK025 - Are Jira API version differences for changelog response format documented? [Gap]
77+
- ✓ research.md §1: "Both Cloud (v3) and Server (v2) support this endpoint" - same structure
78+
- [x] CHK026 - Is graceful degradation behavior when comments API fails specified? [Gap]
79+
- ✓ spec.md §Assumptions: "Comments are already retrieved by the existing system (JiraClient.get_comments already implemented)" - existing error handling applies
80+
81+
---
82+
83+
## Acceptance Criteria Quality
84+
85+
- [x] CHK027 - Is "high" description_quality_score (>70) in US1 acceptance scenario objectively measurable? [Measurability, Spec §US1.4]
86+
- ✓ spec.md §US1.4: "description_quality_score field is high (>70)" - explicit threshold
87+
- [x] CHK028 - Is "high" cross_team_score in US5 acceptance scenario quantified with specific threshold? [Ambiguity, Spec §US5.1]
88+
- ✓ spec.md §US5.1: "cross-team collaboration score is ≥75" - explicit threshold (was fixed in analysis phase)
89+
- [x] CHK029 - Are success criteria SC-001 through SC-006 all independently testable? [Measurability, Spec §Success Criteria]
90+
- ✓ All 6 SCs have measurable outcomes: time-based (SC-001), count-based (SC-002, SC-003), percentage (SC-004), performance (SC-005), boolean (SC-006)
91+
- [x] CHK030 - Is SC-004 (80% identification rate) validation methodology defined? [Clarity, Spec §SC-004]
92+
- ✓ spec.md §SC-004: "identifies at least 80% of issues with insufficient description (< 50 characters or no AC)" - criteria defined
93+
- [x] CHK031 - Is SC-005 (200% performance threshold) baseline measurement specified? [Clarity, Spec §SC-005]
94+
- ✓ spec.md §SC-005: "does not exceed 200% of current base export time" - baseline = current export without metrics
95+
96+
---
97+
98+
## Scenario Coverage
99+
100+
- [x] CHK032 - Are requirements defined for multi-project export scenarios? [Coverage, Gap]
101+
- ✓ contracts/csv-schemas.md §2 Example: shows 2 projects (PROJ, DEV) in single file; ProjectMetrics aggregates by project_key
102+
- [x] CHK033 - Are requirements for empty project (0 issues) export behavior specified? [Coverage, Edge Case]
103+
- ✓ data-model.md §ProjectMetrics Validation: "Division by zero: Return 0.0 for ratios, None for averages" - handles empty projects
104+
- [x] CHK034 - Are requirements for project with all unresolved issues specified for cycle_time aggregation? [Coverage, Edge Case]
105+
- ✓ data-model.md §ProjectMetrics: "avg_cycle_time_days: float | None" + Validation: "None if no data points available"
106+
- [x] CHK035 - Is the behavior for person with 0 resolved issues (avg_cycle_time = null) documented? [Coverage, Data Model]
107+
- ✓ data-model.md §PersonMetrics: "avg_cycle_time_days: float | None" - None for 0 resolved issues
108+
- [x] CHK036 - Are requirements defined for issue types not in standard set (Bug, Story, Task)? [Coverage, Spec §FR-019]
109+
- ✓ spec.md §FR-019: "per issue_type" - aggregates all types; contracts/csv-schemas.md §4 Example shows Epic type
110+
111+
---
112+
113+
## Non-Functional Requirements
114+
115+
- [x] CHK037 - Is the performance target (≤200% of base export time) measurable with specific test methodology? [Measurability, Spec §SC-005]
116+
- ✓ spec.md §SC-005: baseline is "current base export time"; test compares with/without metrics
117+
- [x] CHK038 - Are memory constraints for large dataset processing specified? [Gap, Non-Functional]
118+
- ✓ plan.md §Technical Context: "Handles typical Jira project sizes (hundreds to thousands of issues)" - streaming not required for expected scale
119+
- [x] CHK039 - Is logging level/format for negative cycle_time warnings specified? [Gap, Spec §Edge Cases]
120+
- ✓ constitution §V: "All errors MUST be logged with context (repo, operation, timestamp)" - follows standard logging
121+
- [x] CHK040 - Are CSV file encoding requirements (UTF-8) explicitly documented? [Completeness, Contracts §Validation Rules]
122+
- ✓ contracts/csv-schemas.md §Validation Rules: "Encoding: UTF-8"
123+
124+
---
125+
126+
## Dependencies & Assumptions
127+
128+
- [x] CHK041 - Is the assumption "JiraClient.get_comments already implemented" validated against current codebase? [Assumption, Spec §Assumptions]
129+
- ✓ spec.md §Assumptions: documented as assumption; research.md §4 confirms "JiraClient.get_comments exists"
130+
- [x] CHK042 - Is the assumption "creation and resolution dates always present" contradicted by edge case handling? [Conflict, Spec §Assumptions vs Edge Cases]
131+
- ✓ No conflict: assumption is "for resolved issues"; edge case §CHK015 handles anomalies with warning+null
132+
- [x] CHK043 - Are external dependencies (Jira API version, authentication) documented in plan.md? [Traceability]
133+
- ✓ plan.md §Technical Context: "uses existing JiraClient auth"; research.md §1: "Both Cloud (v3) and Server (v2)"
134+
- [x] CHK044 - Is backward compatibility requirement for existing CSV consumers explicitly stated? [Gap]
135+
- ✓ research.md §6: "Adding columns at end preserves positional parsing"; plan.md §Constraints: "maintain backwards compatibility"
136+
137+
---
138+
139+
## Traceability & Consistency
140+
141+
- [x] CHK045 - Do all 23 functional requirements (FR-001 to FR-023) have corresponding acceptance scenarios? [Traceability]
142+
- ✓ US1 covers FR-001 to FR-009 (issue metrics); US2 covers FR-010 to FR-014 (project); US3 covers FR-015 to FR-018 (person); US4 covers FR-019 to FR-021 (type); US5 covers FR-022 to FR-023 (reopen)
143+
- [x] CHK046 - Is FR-023 (reopen_rate_percent) included in ProjectMetrics CSV schema? [Consistency, Contracts §2 vs Spec §FR-023]
144+
- ✓ contracts/csv-schemas.md §2 Schema: "reopen_rate_percent | float | Reopen percentage | 5.00"
145+
- [x] CHK047 - Are entity field names in data-model.md consistent with CSV column names in contracts? [Consistency]
146+
- ✓ Verified: all field names match (e.g., cycle_time_days, description_quality_score, cross_team_score)
147+
- [x] CHK048 - Is the "reopen_count" field present in both IssueMetrics and extended issue CSV schema? [Consistency]
148+
- ✓ data-model.md §IssueMetrics: "reopen_count: int"; contracts/csv-schemas.md §1: "reopen_count | int | Times reopened"
149+
150+
---
151+
152+
## Notes
153+
154+
- Items marked [Gap] indicate potentially missing requirements
155+
- Items marked [Ambiguity] indicate vague language needing quantification
156+
- Items marked [Conflict] indicate potential contradictions between sections
157+
- Items marked [Consistency] require cross-referencing multiple spec sections
158+
- Focus: Algorithm accuracy, data integrity, API robustness, schema completeness

0 commit comments

Comments
 (0)