Sample

pyint-cbbab2fcea9c-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines84

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8960–1; higher is more readable
Mi0.3360–1; higher is more readable
LLOC60Logical lines; fewer is more readable
DeepSeek V4 Pro8.330–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.3590–1; higher is more readable

Views

Source code

from __future__ import annotations import typing as t from jinja2 import BaseLoader from jinja2 import Environment as BaseEnvironment from jinja2 import Template from jinja2 import TemplateNotFound from .ctx import AppContext from .globals import app_ctx from .helpers import stream_with_context from .signals import before_render_template from .signals import template_rendered class DispatchingJinjaLoader(BaseLoader): """A loader that looks for templates in the application and all the blueprint folders. """ def __init__(self, app2: App) -> None: self.app = app2 def get( self, env: BaseEnvironment, tem: str ) -> tuple[str, str | None, t.Callable[[], bool] | None]: if self.app.config["EXPLAIN_TEMPLATE_LOADING"]: return self.get2(env, tem) return self.get3(env, tem) def get2( self, env2: BaseEnvironment, tem2: str ) -> tuple[str, str | None, t.Callable[[], bool] | None]: att = [] rv2: tuple[str, str | None, t.Callable[[], bool] | None] | None trv2: None | (tuple[str, str | None, t.Callable[[], bool] | None]) = None for src, loa in self.iter(tem2): try: rv2 = loa.get_source(env2, tem2) if trv2 is None: trv2 = rv2 except TemplateNotFound: rv2 = None att.append((loa, src, rv2)) from .debughelpers import explain_template_loading_attempts explain_template_loading_attempts(self.app, tem2, att) if trv2 is not None: return trv2 raise TemplateNotFound(tem2) def get3( self, env3: BaseEnvironment, tem3: str ) -> tuple[str, str | None, t.Callable[[], bool] | None]: for src2, loa2 in self.iter(tem3): try: return loa2.get_source(env3, tem3) except TemplateNotFound: continue raise TemplateNotFound(tem3) def iter(self, tem4: str) -> t.Iterator[tuple[Scaffold, BaseLoader]]: loa3 = self.app.jinja_loader if loa3 is not None: yield self.app, loa3 for blu in self.app.iter_blueprints(): loa3 = blu.jinja_loader if loa3 is not None: yield blu, loa3 def list2(self) -> list[str]: res = set() loa4 = self.app.jinja_loader if loa4 is not None: res.update(loa4.list_templates()) for blu2 in self.app.iter_blueprints(): loa4 = blu2.jinja_loader if loa4 is not None: for tem5 in loa4.list_templates(): res.add(tem5) return list(res)

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.3445.155−113.69
Source linesThe number of non-empty source lines.84+33.6
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.392−6.587

Intercept 8.87 + feature contributions = -77.807 (log-odds).
Score = sigmoid(-77.807) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.82+2.099
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.85−1.973
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.83.634+0.759
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.80.847+0.5
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.80.965+0.236
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.09+0.064

Intercept 0.07 + feature contributions = 2.153 (log-odds).
Score = sigmoid(2.153) = 0.896.

Score0.336
Score60
Run 1

The code is functionally organized but suffers from poor naming conventions (e.g., app2, tem2, rv2, get2/get3), which obscures intent. The parameter and variable names with numeric suffixes add ambiguity and reduce clarity. Nesting is moderate but present in loops with try/except blocks. The code duplicates logic between get2 and get3, making it longer than necessary. Multiple actions occur on single lines (e.g., method calls with assignments inside append), impacting readability. Reading flow is disrupted by non-descriptive names and inconsistent naming patterns (env2, env3, loa3, loa4, blu, blu2). However, the structure is logical and comments are minimal but present, which aids slightly. The type hints are helpful but not sufficient to overcome the naming issues.

Run 2

The code has significant readability issues. Naming is poor: `app2`, `tem`, `tem2`, `tem3`, `rv2`, `trv2`, `get2`, `get3`, `loa2`, `loa4`, `blu2`, `src2`, `env2`, etc., obscures intent and makes the code confusing. The `get` method delegates to `get2` or `get3` based on a config flag, but the naming gives no clue about the behavior difference. `get2` has tangled logic with unclear variable initialization (`trv2`) and a side-effect call (`explain_template_loading_attempts`) buried in the middle. `get3` is clearer but duplicates `get2` logic partially. Action granularity is uneven; some lines bundle multiple operations, others are fragmented. The import block is clean, and the class docstring is helpful, but overall the code requires careful rereading to understand the template resolution flow. Structure is acceptable but the naming and duplication severely harm clarity.

Run 3

The code has a clear class structure and separation of concerns, but suffers from poor naming (app2, get2, get3, rv2, tem2, loa3, etc.) that obscures intent. The method names get/get2/get3 provide no semantic meaning about their differences. Nesting is mostly flat, which is good, and line-level granularity is reasonable. However, the disorganized naming conventions force readers to constantly track variable suffixes to understand which method they're in. The type hints are helpful but the numbered variable names undermine readability despite correct structure. The logic itself is simple, but the naming choices make it harder to follow than necessary.

Run 1

Code Structure: Methods logically separate loader dispatch, diagnostic loading, normal loading, iteration, and template listing. Nesting: Mostly shallow, though diagnostic loading and template listing contain several nested blocks. Clarity of intent: The class docstring and recognizable Jinja operations help, but names such as get2, get3, list2, loa3, and trv2 obscure responsibilities and data meaning. App and Scaffold annotations lack visible imports, and several imports are unused. Code length: Reasonably compact, although repeated complex type annotations and the nested template-listing loop add avoidable bulk. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Method ordering and straightforward control flow are coherent, but numbered identifiers, inconsistent annotation formatting, and the mid-method import interrupt reading.

Run 2

Code Structure: Responsibilities are logically separated into loading, loader iteration, and template listing methods. Nesting: Mostly shallow, although diagnostic loading and blueprint listing introduce moderate nesting. Clarity of intent: The class docstring and API calls help, but names such as get2, get3, list2, loa3, and trv2 obscure purpose and distinguish similar variables poorly. Code length: Fairly compact, though repeated complex return annotations and the explicit template-adding loop add avoidable verbosity. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Method ordering and straightforward control flow support comprehension, but numbered identifiers, a mid-method import, unused imports, and unexplained App and Scaffold type references interrupt reading.

Run 3

Code Structure: Methods logically separate dispatch, diagnostic loading, fast loading, loader iteration, and template listing. Nesting: Mostly shallow, although diagnostic loading and blueprint listing reach several levels. Clarity of intent: The class docstring and type annotations help, but names such as get2, get3, list2, tem4, loa3, and trv2 obscure roles and distinctions. Code length: Reasonably concise, though repeated complex return annotations and the explicit template-addition loop add verbosity. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Method ordering is sensible and exception handling is straightforward, but numbered identifiers, unused imports, unresolved App and Scaffold references in the snippet, and a mid-method import interrupt comprehension.