COBOL Quality
A VS Code extension that provides static analysis for COBOL code quality. Automatically detects unused variables, indentation violations, and other code quality issues directly in your editor.
Features
Current Features
Unused Variable Detection - Identifies variables declared in WORKING-STORAGE or LOCAL-STORAGE sections that are never referenced in your code
- Automatically excludes level-88 condition names, FILLER items, LINKAGE SECTION variables, REDEFINES, and GLOBAL declarations
- Level-01 group items are only flagged as unused when all of their sub-variables are also unreferenced
- Shows as greyed-out text with
DiagnosticTag.Unnecessary
Indentation Validation - Enforces COBOL column formatting rules
- Validates Area A (columns 8-11) for divisions, sections, and paragraph headers
- Validates Area B (columns 12-72) for statements
- Automatically detects and respects free-format mode (
>>SOURCE FORMAT FREE)
- COBOL scope terminators (
END-EXEC, END-IF, END-PERFORM, etc.) are correctly excluded from paragraph header detection
Real-time Analysis - Code is analyzed automatically:
- When you open a COBOL file
- When you save changes
- When you switch between open files
Integrated with VS Code Problems Panel - All findings appear as inline squiggles and in the Problems panel with clear descriptions
Supported File Types
.cbl - COBOL source files
.cob - COBOL source files
.cobol - COBOL source files
.cpy - COBOL copybook files
Planned Features
- Unused section/paragraph detection
- Cryptic identifier detection
- Duplicate code detection
- Configuration options for rule severity
- Dedicated sidebar tree view panel
Installation
From VS Code Marketplace (Recommended)
- Open VS Code
- Go to the Extensions view (
Ctrl+Shift+X or Cmd+Shift+X on Mac)
- Search for "COBOL Quality"
- Click Install
From VSIX File
If you have a .vsix file:
- Open VS Code
- Go to Extensions view (
Ctrl+Shift+X or Cmd+Shift+X)
- Click the
... menu at the top of the Extensions view
- Select "Install from VSIX..."
- Navigate to and select the
.vsix file
Usage
Simply open any COBOL file (.cbl, .cob, .cobol, or .cpy) and the extension will automatically analyze your code.
Issues will appear as:
- Yellow squiggles for warnings (e.g., unused variables)
- Red squiggles for errors (e.g., indentation violations)
- Entries in the Problems panel (
Ctrl+Shift+M or Cmd+Shift+M)
Example Issues Detected
WORKING-STORAGE SECTION.
01 WS-COUNTER PIC 9(4). *> Warning: Unused variable
01 WS-NAME PIC X(20).
PROCEDURE DIVISION.
DISPLAY WS-NAME. *> Only WS-NAME is used
STOP RUN.
Development & Deployment
Prerequisites
- Node.js (v20 or higher)
- npm
- VS Code
Setup Development Environment
- Clone the repository:
git clone https://github.com/shimf/CobolQuality.git
cd CobolQuality
- Install dependencies:
npm install
- Open in VS Code:
code .
- Press
F5 to launch the Extension Development Host
Building the Extension
To compile the extension:
npm run compile
To build for production:
npm run package
Running Tests
Run all tests:
npm test
Run unit tests only:
npm run test:unit
Creating a VSIX Package
- Install the VS Code Extension Manager (vsce):
npm install -g @vscode/vsce
- Package the extension:
vsce package
This creates a .vsix file (e.g., cobol-quality-0.0.2.vsix) in the root directory.
Publishing to VS Code Marketplace
First Time Setup
Create a publisher account at Visual Studio Marketplace
Get a Personal Access Token from Azure DevOps:
- Create a new token with
Marketplace (Manage) scope
- Save the token securely
Login with vsce:
vsce login <publisher-name>
Publishing
- Update the version in
package.json:
{
"version": "0.0.3"
}
- Publish the extension:
vsce publish
Or publish a specific version:
vsce publish minor # 0.0.2 -> 0.1.0
vsce publish patch # 0.0.2 -> 0.0.3
vsce publish major # 0.0.2 -> 1.0.0
Manual Upload
Alternatively, you can manually upload the .vsix file:
- Go to Visual Studio Marketplace Publisher Portal
- Click your publisher
- Click "New Extension" > "Visual Studio Code"
- Upload the
.vsix file
Project Structure
CobolQuality/
├── src/
│ ├── analyzer/ # Core analysis engine
│ │ ├── index.ts # Main analyzer entry point
│ │ ├── scanner.ts # COBOL line scanner
│ │ ├── symbolTable.ts # Symbol table builder
│ │ ├── types.ts # Type definitions
│ │ └── rules/ # Analysis rules
│ │ ├── indentation.ts
│ │ └── unusedVariables.ts
│ ├── providers/
│ │ └── diagnosticProvider.ts # VS Code diagnostics integration
│ ├── utils/
│ │ └── document.ts # Document utilities
│ └── extension.ts # Extension entry point
├── test/ # Test suite
├── dist/ # Compiled output
├── package.json # Extension manifest
└── tsconfig.json # TypeScript configuration
Configuration
Currently, the extension works out of the box with no configuration required. Future versions will support:
- Rule severity customization
- Naming conventions
- Duplicate code thresholds
- Copybook search paths
Compatibility
- VS Code Version: 1.74.0 or higher
- COBOL Dialect: Rocket Software (Microfocus) COBOL
- Works alongside: Rocket COBOL VS Code extension
Known Limitations
- COPY statements: Copybooks are not resolved in v1. Variables from copybooks may be flagged as unused.
- ALTER statements: Not yet handled for reachability analysis.
- Multi-file analysis: Cross-file PERFORM tracking not yet implemented.
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
MIT License - see the LICENSE file for details
Support
Roadmap
The extension is being developed in phases:
- Phase 1 ✓ - Indentation rules & VS Code integration
- Phase 2 ✓ - Unused variable detection
- Phase 3 (In Progress) - Unused section/paragraph detection
- Phase 4 - Cryptic identifier detection
- Phase 5 - Duplicate code detection
See the project documentation for detailed roadmap information.
Made with ❤️ for the COBOL developer community