User Tools

Site Tools


en:devmon:guidelines:tidy

This is an old revision of the document!


Tidy

To make it easier to keep code clean, you can follow this guide

Objective

  • Tidy perl code, … (perltidy)
  • Follow best practice (perlcritic)
  • Automate it (tidyall)

Installation Cpan minus (cpanm) install latest package, but this can break be in conflict with OS package manager. Make a backup if you can first.

cpanm install Perl::Tidy
cpanm install Perl::Critic
cpanm install Code::TidyAll

“TidyAll” automates the code formating (perltidy) and the code review (perlcritic). In the project folder, you will find a file called: “.tidyallrc” that contains the current configuration. Look at it to undestand what it does.

To simulate the result:

tidyall -a --check-only 

To make it work (perltidy will reformat files with an inplace reformatting, perlcritic will review code, but do not change any files)

To simulate the result:

tidyall -a 

And files are bakuped ind the “.tidyall.d” folder (add it to your git ignore files, if not already)

Current Best Practice for Tidy

(Can change at any time: submit your proposal, critics)
Similar to arg -pbp (perl best practice), mainly:

  • 4 chars
  • no tabs
  • Line lenght 118
  • Cuddle else ( else stay on the same line as the parenthesis)

Best Practice for Critic

(Wip, Not Implemented, nor deployed)

Use modern default:

  • use strict;
  • use warning;
  • use utf8;
en/devmon/guidelines/tidy.1628753572.txt.gz · Last modified: 2021/08/12 09:32 by Bruno Manzoni