loot / loot.github.io

The website and meta issue tracker.
https://loot.github.io
GNU General Public License v3.0
12 stars 9 forks source link

Convert block style single-element lists to flow style #73

Closed sibir-ine closed 3 years ago

sibir-ine commented 3 years ago

I've noticed that throughout most of the masterlists, there are quite a few lists that have only one element that aren't written in flow style. Here's an example from the SSE masterlist:

  - name: 'InnoLostAlt.esp'
    url: [ 'https://www.nexusmods.com/skyrimspecialedition/mods/24236' ]
    after:
      - 'TheChoiceIsYours.esp'
    clean:
      - crc: 0x7D8AB5D7
        util: 'SSEEdit v4.0.3'

The after can be rewritten as:

    after: [ 'TheChoiceIsYours.esp' ]

It's not a big deal, but it's definitely tidier that way. It's also done in most plugins nowadays, so it's worth doing for the sake of consistency.

@MacSplody did a lot of work towards this goal for the SSE masterlist in loot/skyrimse#978, the TES5 masterlist in loot/skyrim#311, & the TES4 masterlist in loot/oblivion#94 & loot/oblivion#72.

At the time of writing, I found 1 instance in the TES3 masterlist, 1 instance in the TES4 masterlist, 4 instances in the SSE masterlist, 18 instances in the TES5 masterlist, 73 instances in the FO4 masterlists, & about 493(!) instances in the FNV masterlist.

I found this out by searching the masterlists with a regex, specifically : *\n {3,}-.*\n {2,4}(?! ), to find most occurrences, taking advantage of the expected indentation of such an element & how it will be preceded by a colon & newline & followed by a less indented line. I also tried to factor in erroneous spaces & indentation (it still caught a few false positives from bad indentation). Any improvements to the regex are very welcome.

I further refined the regex, : *\n {3,}-[^\n|]*\n( {2,4}(?! )|\n+), to catch a few more instances it missed before, such as when a single-element list is followed by multiple newlines & either a new element or a non-indented line (e.g., a comment). The exclusion of the | character is to avoid 2 false positives in the TES5 masterlist. This caught 1 more instance in the FO3 & FNV masterlists, 2 in the TES3 masterlist, & 9 in the FO4 masterlist.