Skip to content

The eol_at_end_of_file lint reads file content from disk and can slow down linting #59704

Closed
@DanTup

Description

@DanTup

Splitting this out of #55281 (comment) so it doesn't get lost.

This lint reads the content in a way that appears that it can hit the disk and can be quite slow when analyzing a lot of files (or a large library):

var content = node.declaredFragment?.source.contents.data;

One simple option suggested by @bwilkerson was:

    var unitContext =
        context.allUnits.firstWhereOrNull((unit) => unit.unit == node);
    var content = unitContext.content;

And @scheglov:

And yes, I think registerNodeProcessors() should have access to the current LintRuleUnitContext instance. Currently it knows all units of the library, and its defining unit, but not the current.

I had a quick look at this, but I am a little confused by LinterContext.definedUnit because it seems like there is code that passes each individual unit in for it. For example this call here happens inside a loop for all units within a library (called currentUnit):

_computeParsedResultLint(unitContext, unitContexts);

And then currentUnit is passed as definingUnit:

var context = LinterContextWithParsedResults(allUnits, currentUnit);

So I wonder whether definingUnit could just be rename and repurposed as currentUnit or whether any lints really do need/want the defining unit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestdevexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions