Skip to content

Refactor long lines exceeding 100 characters #487

@suparious

Description

@suparious

Description

Per CONTRIBUTING.md, lines should be kept below 100 characters. The codebase has approximately 51 code lines exceeding this limit (excluding ASCII art and help text which are acceptable exceptions).

Scope

Lines over 100 characters fall into these categories:

High-priority (complex code)

  • Lines 2800-2801: Complex awk command for media player parsing (~150 chars)
  • Various parameter expansion chains for distro detection

Medium-priority (could be split)

  • Long conditional statements
  • String assignments with multiple fallbacks

Acceptable exceptions (no action needed)

  • ASCII art (Unicode logos like Tux variants)
  • Help text listing supported distros
  • Comments

Example refactors

Before (line 2800-2801):

awk -F '"' 'BEGIN {RS=" entry"}; /"xesam:artist"/ {a = $4} /"xesam:album"/ {split($0,b,"\""); for(i=5;i<length(b);i++)b[4]=b[4] "\"" b[i]}
            /"xesam:title"/ {split($0,t,"\""); for(i=5;i<length(t);i++)t[4]=t[4] "\"" t[i]} END {print a " \n" b[4] " \n" t[4]}'

After (split with backslash continuation):

awk -F '"' 'BEGIN {RS=" entry"};
    /"xesam:artist"/ {a = $4}
    /"xesam:album"/ {split($0,b,"\""); for(i=5;i<length(b);i++)b[4]=b[4] "\"" b[i]}
    /"xesam:title"/ {split($0,t,"\""); for(i=5;i<length(t);i++)t[4]=t[4] "\"" t[i]}
    END {print a " \n" b[4] " \n" t[4]}'

Audit command

Find violations:

awk 'length > 100 {print NR": "length" chars"}' neofetch | grep -v ASCII

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityCode style and quality improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions