Skip to content

Improve analysis of files with consistent indentation where offset is guessed wrongly due to merging #68

@NateEag

Description

@NateEag

dtrt-indent (version 20230302.2151) guesses the following file has an offset of 4, when 2 is what I'd expect:

declare namespace NodeJS {
  interface ProcessEnv {
    NODE_ENV: string;

    FOOBAR: string;
    BAR: string;
    BAZ: string;

    TEST?: string;
    TEST2?: string;
    TEST3?: string;

    OPTION: string;
    ANOTHER_OPTION: string;
    MORE_OPTIONS: string;
  }
}

Output of dtrt-indent-diagnosis:

Guessing offset for /Users/nathaneagleson/schedule-engine/servicechannel-integration/test.ts

Elapsed time for analysis: 0.000 seconds

Total relevant lines: 12 out of 18 (limit: 5000)

Histogram:

     2x   2 spaces
    10x   4 spaces

Analysis:

  offset 2 works for 100.00% of relevant lines, matching 2 distinct offsets - merged with offset 4 (16.67% deviation, limit 20.00%)
  offset 4 works for  83.33% of relevant lines, matching 1 distinct offsets - CONSIDERED
  offset 3 works for   0.00% of relevant lines, matching 0 distinct offsets - rejected: too few distinct matching offsets (1 required)
  offset 5 works for   0.00% of relevant lines, matching 0 distinct offsets - rejected: too few distinct matching offsets (1 required)
  offset 6 works for   0.00% of relevant lines, matching 0 distinct offsets - rejected: too few distinct matching offsets (1 required)
  offset 7 works for   0.00% of relevant lines, matching 0 distinct offsets - rejected: too few distinct matching offsets (1 required)
  offset 8 works for   0.00% of relevant lines, matching 0 distinct offsets - rejected: too few distinct matching offsets (1 required)

Summary:

  Best guess is offset 4 with 83.33% matching lines (80.00% required)
  Hard tab percentage: 0.00% (0 lines), -100.00% superior to soft tabs (threshold 300.00%)
  Soft tab percentage: 100.00% (12 lines), inf% superior to hard tabs (threshold 300.00%)

Conclusion:

  Guessed offset 4 with 83% confidence.
  Change indent-tab-setting: yes, to nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions