quality-metrics
Test coverage, code quality, defect metrics, and QA KPIs
What this skill does
# Quality Metrics ## Test Coverage Metrics ### Code Coverage Types - **Line Coverage**: Percentage of executable lines executed - **Branch Coverage**: Percentage of conditional branches taken - **Function Coverage**: Percentage of functions/methods called - **Statement Coverage**: Percentage of statements executed - **Condition Coverage**: Percentage of boolean sub-conditions evaluated ### Coverage Targets ``` Critical Business Logic: 90-100% Core Application Code: 80-90% Utility/Helper Code: 70-80% Configuration/Setup Code: 50-70% ``` ### Coverage Tools - **JavaScript**: Istanbul, nyc, Jest coverage - **Python**: pytest-cov, coverage.py - **Java**: JaCoCo, Cobertura - **.NET**: dotCover, Coverlet - **Go**: go test -cover ### Coverage Best Practices - Focus on meaningful coverage, not just percentage - Prioritize coverage of critical paths - Track coverage trends over time - Set coverage gates in CI/CD - Review uncovered code regularly ## Code Quality Metrics ### Cyclomatic Complexity - Measures code complexity based on control flow - Higher complexity = harder to test and maintain - Target: < 10 per function/method ``` Complexity Levels: 1-10: Simple, low risk 11-20: Moderate complexity, medium risk 21-50: High complexity, high risk 50+: Very high complexity, very high risk ``` ### Maintainability Index - Composite metric combining complexity, volume, and structure - Scale: 0-100 (higher is better) - Target: > 70 ``` Maintainability Levels: 85-100: Highly maintainable 70-84: Moderately maintainable 50-69: Difficult to maintain 0-49: Very difficult to maintain ``` ### Code Duplication - Percentage of duplicated code - Target: < 5% - High duplication indicates need for refactoring ### Code Smells - **Long Methods**: Methods > 50 lines - **Large Classes**: Classes > 500 lines - **Deep Nesting**: Nesting > 4 levels - **Long Parameter Lists**: > 4 parameters - **Feature Envy**: Methods using other objects more than their own ### Technical Debt Ratio ``` Technical Debt Ratio = Cost to Fix Issues / Cost to Develop New Features Target: < 5% ``` ## Defect Metrics ### Defect Density - Defects per thousand lines of code (KLOC) - Defects per function point - Defects per module/component ``` Defect Density = Total Defects / Size Metric (KLOC, FP) Target: < 1 defect per KLOC ``` ### Defect Removal Efficiency (DRE) - Percentage of defects found before release - Higher is better ``` DRE = (Defects Found Before Release / Total Defects) × 100 Target: > 90% ``` ### Defect Leakage - Percentage of defects found after release - Lower is better ``` Defect Leakage = (Defects Found After Release / Total Defects) × 100 Target: < 10% ``` ### Defect Age - Time from defect introduction to detection - Time from defect detection to resolution ``` Defect Age = Detection Date - Introduction Date Resolution Time = Resolution Date - Detection Date Target: < 7 days for critical defects ``` ### Defect Severity Distribution - **Critical**: System failure, data loss - **High**: Major functionality broken - **Medium**: Minor functionality broken - **Low**: Cosmetic issues, typos ### Defect Trend Analysis - Track defects over time - Identify patterns and trends - Correlate with code changes - Predict future defect rates ## Quality Gates and Acceptance Criteria ### Quality Gate Examples ``` Code Quality Gate: - Code coverage ≥ 80% - No critical or high severity defects - Cyclomatic complexity ≤ 10 - No security vulnerabilities - All tests passing Performance Gate: - p95 response time < 500ms - Error rate < 0.1% - Throughput ≥ 1000 RPS - CPU utilization < 70% Security Gate: - No high/critical vulnerabilities - OWASP Top 10 compliance - Dependency scan clean - Authentication/authorization tested ``` ### Acceptance Criteria - **Functional Requirements**: All features work as specified - **Non-Functional Requirements**: Performance, security, usability met - **Test Coverage**: Minimum coverage thresholds met - **Defect Standards**: No defects above acceptable severity - **Documentation**: All documentation complete and accurate ## Test Reporting and Dashboards ### Test Execution Reports - Total tests run - Pass/fail counts and percentages - Test execution time - Flaky test identification - Test failure categorization ### Coverage Reports - Line, branch, function coverage - Coverage by module/component - Uncovered code highlighting - Coverage trends over time - Coverage comparison between branches ### Defect Reports - Open defects by severity - Defect trends and patterns - Defect age distribution - Defect resolution time - Defect density by module ### Performance Reports - Response time metrics (p50, p95, p99) - Throughput metrics - Error rates - Resource utilization - Performance trends over time ### Dashboard Elements - Overall quality score - Test coverage gauge - Defect trend chart - Performance metrics - Build health status - Quality gate status ## QA KPIs and Metrics Tracking ### Process Metrics - **Test Execution Time**: Time to run test suite - **Test Automation Rate**: Percentage of tests automated - **Test Case Count**: Total number of test cases - **Test Case Execution**: Number of tests executed per period - **Defect Detection Rate**: Defects found per testing hour ### Product Metrics - **Defect Escape Rate**: Defects found in production - **Mean Time to Detection**: Time to find defects - **Mean Time to Resolution**: Time to fix defects - **Customer Reported Defects**: Defects reported by users - **Test Coverage**: Code, feature, and requirement coverage ### Team Metrics - **Test Case Productivity**: Test cases created per person-hour - **Automation Productivity**: Automated tests created per person-hour - **Defect Detection Efficiency**: Defects found per person-hour - **Test Execution Efficiency**: Tests executed per person-hour ### Quality Metrics - **Overall Quality Score**: Composite quality metric - **Test Pass Rate**: Percentage of passing tests - **Defect Density**: Defects per size metric - **Code Quality Score**: Based on complexity, duplication, smells - **Performance Score**: Based on response time, throughput, errors ### Metrics Dashboard ``` Quality Dashboard: ┌─────────────────────────────────────────┐ │ Overall Quality Score: 87/100 │ ├─────────────────────────────────────────┤ │ Test Coverage: 85% │ │ ├─ Line: 87% │ │ ├─ Branch: 82% │ │ └─ Function: 90% │ ├─────────────────────────────────────────┤ │ Code Quality: 82/100 │ │ ├─ Complexity: 8.2 avg │ │ ├─ Duplication: 3.1% │ │ └─ Maintainability: 78 │ ├─────────────────────────────────────────┤ │ Defects: 12 open │ │ ├─ Critical: 1 │ │ ├─ High: 3 │ │ ├─ Medium: 5 │ │ └─ Low: 3 │ ├─────────────────────────────────────────┤ │ Performance: 92/100 │ │ ├─ p95 Response: 420ms │ │ ├─ Throughput: 1250 RPS │ │ └─ Error Rate: 0.05% │ └─────────────────────────────────────────┘ ``` ## Metrics Collection and Analysis ### Data Collection - Automated collection from CI/CD pipelines - Integration with test frameworks - Real-time monitoring and alerts - Historical data storage - Data normalization and aggregation ### Analysis Techniques - Trend analysis over time - Comparison between branches/releases - Correlation with code changes - Root cause analysis of quality issues - Predictive analytics for quality forecasting ### Reporting Frequency - **Real-time**: Build status, test failures, critical defects - **Daily**: Test execution, defect updates, performance metrics - **Weekly**: Quality trends, coverage reports, team metrics - **Monthly**: Quality scorecards, process improvements, strategic insights - **Quart
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.