STUD.com
← Objectives

Calculate · Assess & Decide · Engineering

Maintainability index per module

The Maintainability Index (raw and 0-100 normalized) per module from Halstead volume, cyclomatic complexity, and lines of code, with a maintainability band.

You receive: A reviewed maintainability-index calculator + the passing test report, run on your module metrics.

Part of Ship MVP

Opens soon

Cost15 credits
AcceptanceAutomated check against your inputs
ProtectionHeld until verified delivery

This objective is verified and ready. It opens soon, once sign-in and payments are live.

Deliverable interface

The exact vocabulary the automated check enforces: keys, tokens, entry points, and worked examples. Generated from the verification source.

{
 "constants": {},
 "entryName": "compute_maintainability_index",
 "expectNote": "expect is the comparison-space value (your return value goes through normalize first when one is published)",
 "hiddenCaseCount": 6,
 "hiddenCaseNames": [
  "low_band",
  "clamped_to_zero",
  "custom_bands",
  "raw_scale",
  "two_modules",
  "invalid_zero_volume"
 ],
 "inputKeys": [
  "band_thresholds",
  "cyclomatic_complexity",
  "good_min",
  "halstead_volume",
  "loc",
  "moderate_min",
  "modules",
  "name",
  "rounding_dp",
  "scale"
 ],
 "normalizeSource": "def _mi_normalize(r):\n    if isinstance(r, str):\n        return r  # sentinel (invalid_module) passes through\n    try:\n        return {\"rows\": [{\"name\": str(x[\"name\"]), \"mi_raw\": round(float(x[\"mi_raw\"]), 6),\n                          \"mi_100\": round(float(x[\"mi_100\"]), 6), \"band\": str(x[\"band\"])} for x in r[\"rows\"]]}\n    except Exception:\n        return repr(r)\n",
 "returnShapes": [
  [
   "rows"
  ],
  "invalid_module"
 ],
 "signature": "def compute_maintainability_index(inp):",
 "submission": "python exposing the entry function; inp is one input object; graded on held-out cases",
 "tier": "calculator",
 "visibleCases": [
  {
   "expect": {
    "rows": [
     {
      "band": "good",
      "mi_100": 27.45,
      "mi_raw": 46.95,
      "name": "a"
     }
    ]
   },
   "input": {
    "modules": [
     {
      "cyclomatic_complexity": 10,
      "halstead_volume": 1000,
      "loc": 200,
      "name": "a"
     }
    ]
   },
   "name": "moderate_module"
  },
  {
   "expect": {
    "rows": [
     {
      "band": "good",
      "mi_100": 59.45,
      "mi_raw": 101.67,
      "name": "b"
     }
    ]
   },
   "input": {
    "modules": [
     {
      "cyclomatic_complexity": 2,
      "halstead_volume": 50,
      "loc": 20,
      "name": "b"
     }
    ]
   },
   "name": "clean_small_module"
  }
 ],
 "vocabulary": [
  "0-100",
  "band",
  "band_thresholds",
  "cyclomatic_complexity",
  "good",
  "good_min",
  "halstead_volume",
  "invalid_module",
  "loc",
  "low",
  "mi_100",
  "mi_raw",
  "moderate",
  "moderate_min",
  "modules",
  "name",
  "rounding_dp",
  "rows",
  "scale"
 ]
}

Get early access to STUD the day it goes live.