On Thu, 16 Mar 2023 19:49:27 +0100, demerphq <demerphq@gmail.com> wrote: > I wrote some code some time back which was intended to auto format all of > our documentation, side-bar comments, and etc, so that they respected our > "80 column preference". > > So I would like to propose that we standardize our text to use one space > after a full stop, and make it "ok" to reformat any text that uses two > spaces after a full stop to have only one. Such matters should be left up > to rendering tools, and we should not impose tedious manual work on our > devs. While well meant, the solution here shoots past the /achieve. Some experience from my time in the field indicates the best solution here is to apply a lenient measurement and test that complains when a test suite is run, and leaves it to the author whether to ignore it or apply changes. In my particular case this stems from having a perl critic script that complains about policies, but only considers the changes of the past few commits, skipping files that have not been changed substantially. Even myself will often ignore it on account of time constraints, but on the whole it helps without being a hindrance. ``` use Test::Perl::Critic 'critic_ok'; ...; critic_ok($_) for big_perl_changes_since_previous_commit(); sub commits { "HEAD~" . ( $ARGV[0] // 1 ) } sub git_diff { capture qw( git diff ), shift, commits(), @_ } sub change_count { ( split ' ', ( git_diff "--stat", $_[0] )[0] )[2] } sub change { change_count( $_[0] ) / capture " <$_[0] wc -l " } sub big_perl_changes_since_previous_commit { const my $LIMIT_FOR_SELECT => 0.05; return ## skip files with minor changes grep change($_) >= $LIMIT_FOR_SELECT, ## skip deleted files from git history grep -e, ## perl files only (also split on newline) map /^(.*[.](?:pm|pl|psgi|t))$/, ## files in recent commit range, including outstanding changes ( git_diff "--name-only" ); } ``` (Cheers to mst for some of the fine-tuning on this.) -- With regards, Christian WaldeThread Previous | Thread Next