MetaLint: Easy-to-Hard Generalization for Code Linting

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Naik, Atharva, Baghel, Lawanya, Govindarajan, Dhakshin, Agrawal, Darsh, Xie, Yiqing, Fried, Daniel, Rose, Carolyn
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917418858708992
author Naik, Atharva
Baghel, Lawanya
Govindarajan, Dhakshin
Agrawal, Darsh
Xie, Yiqing
Fried, Daniel
Rose, Carolyn
author_facet Naik, Atharva
Baghel, Lawanya
Govindarajan, Dhakshin
Agrawal, Darsh
Xie, Yiqing
Fried, Daniel
Rose, Carolyn
contents Large language models excel at code generation but struggle with code linting, particularly in generalizing to unseen or evolving best practices beyond those observed during training. We introduce MetaLint, a meta-learning framework that formulates code linting as an instruction-following task, where a model evaluates whether code adheres to a natural language specification of best practices. In contrast to prior work that trains models to detect violations from a fixed set of best practices, MetaLint evaluates code against a provided natural language specification, enabling test-time control over which practices to enforce and generalization to unseen or evolving rules without retraining. We demonstrate that models trained solely on synthetic data generated from automatic linters still generalize to harder, context-dependent best practices for which such linters are not available. To evaluate generalization beyond such easy signals, we introduce a human-curated benchmark of hard best practices inspired by Python Enhancement Proposals (PEPs). On this benchmark, MetaLint substantially improves performance without explicit fine-tuning on target best practices and exhibits strong, easy-to-hard generalization. Qwen3-4B achieves a 2.7x detection F-score gain (25.9% -> 70.4%), the highest recall, and a 26.7% localization F-score, matching larger models such as o3-mini. These gains generalize across programming languages, model families, scales, reasoning settings, and linter sources. We release the code and benchmark to support reproducibility and future work.
format Preprint
id arxiv_https___arxiv_org_abs_2507_11687
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle MetaLint: Easy-to-Hard Generalization for Code Linting
Naik, Atharva
Baghel, Lawanya
Govindarajan, Dhakshin
Agrawal, Darsh
Xie, Yiqing
Fried, Daniel
Rose, Carolyn
Software Engineering
Computation and Language
Machine Learning
Large language models excel at code generation but struggle with code linting, particularly in generalizing to unseen or evolving best practices beyond those observed during training. We introduce MetaLint, a meta-learning framework that formulates code linting as an instruction-following task, where a model evaluates whether code adheres to a natural language specification of best practices. In contrast to prior work that trains models to detect violations from a fixed set of best practices, MetaLint evaluates code against a provided natural language specification, enabling test-time control over which practices to enforce and generalization to unseen or evolving rules without retraining. We demonstrate that models trained solely on synthetic data generated from automatic linters still generalize to harder, context-dependent best practices for which such linters are not available. To evaluate generalization beyond such easy signals, we introduce a human-curated benchmark of hard best practices inspired by Python Enhancement Proposals (PEPs). On this benchmark, MetaLint substantially improves performance without explicit fine-tuning on target best practices and exhibits strong, easy-to-hard generalization. Qwen3-4B achieves a 2.7x detection F-score gain (25.9% -> 70.4%), the highest recall, and a 26.7% localization F-score, matching larger models such as o3-mini. These gains generalize across programming languages, model families, scales, reasoning settings, and linter sources. We release the code and benchmark to support reproducibility and future work.
title MetaLint: Easy-to-Hard Generalization for Code Linting
topic Software Engineering
Computation and Language
Machine Learning
url https://arxiv.org/abs/2507.11687