Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce EditorConfig #681

Merged
merged 3 commits into from
Nov 6, 2023
Merged

Introduce EditorConfig #681

merged 3 commits into from
Nov 6, 2023

Conversation

szepeviktor
Copy link
Contributor

@szepeviktor szepeviktor commented Sep 18, 2023

  • The contributed code is licensed under GPL v2.0
  • Contributor Licence Agreement (CLA) is signed
  • util/update-modules has been ran
  • Documentation updated
  • Test suite update

@szepeviktor szepeviktor marked this pull request as draft September 18, 2023 14:20
.editorconfig Outdated Show resolved Hide resolved
@svetasmirnova
Copy link
Collaborator

@szepeviktor, what is the status of your PR? Are you still working on it and want to keep it draft?

@szepeviktor
Copy link
Contributor Author

Finishing it right away.

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Nov 3, 2023

Using consistent (by simply counting spaces) indentation is a no-go for perl code.
I've just installed cpanminus and issued cpanm Perl::Tidy

Parenthesis spacing is so chaotic in the code that I'm unable to select a style.
https://perltidy.sourceforge.net/tutorial.html#bt--pt--sbt:-Container-tightness
Should it be -pt=0 or -pt=1 or -pt=2? Please help me.

For example

perltidy -b -i=3 -l=120 -pt=1 bin/pt-visual-explain
git diff -- bin/pt-visual-explain

@svetasmirnova
Copy link
Collaborator

svetasmirnova commented Nov 3, 2023

Percona Toolkit is based on Maatikit product. Here are the coding standards for Maatkit: https://code.google.com/archive/p/maatkit/wikis/CodingStandards.wiki. They were not fully followed in recent years but I believe we can restore them.

Here is example config for perltidy:
Example .perltidyrc file:

-l=78 # Max line width is 78 cols 
-i=3 # Indent level is 4 cols 
-ci=3 # Continuation indent is 4 cols 
-b # In-place update
#-st # Output to STDOUT 
-se # Errors to STDERR 
-vt=2 # Maximal vertical tightness 
-cti=0 # No extra indentation for closing brackets 
-pt=1 # Medium parenthesis tightness 
-bt=1 # Medium brace tightness 
-sbt=1 # Medium square bracket tightness 
-bbt=1 # Medium block brace tightness 
-nsfs # No space before semicolons 
-nolq # Don't outdent long quoted strings 
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" 

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Nov 3, 2023

Thank you.
I will run perltidy on all perl files and that is the end of this PR.

-b
-l=100 # Max line width
-i=3 # Indent level
-ci=3 # Continuation indent
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
-bt=1 # Medium brace tightness
-sbt=1 # Medium square bracket tightness
-bbt=1 # Medium block brace tightness
-nsfs # No space before semicolons
-nolq # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Nov 3, 2023

git ls-files -- 'lib/**.pm' | xargs -t -L 1 -- perltidy

perltidy makes artistic indentations go away

- sub _d {
-    my ($package, undef, $line) = caller 0;
-    @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
-         map { defined $_ ? $_ : 'undef' }
-         @_;
-    print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
- }

+    sub _d {
+       my ( $package, undef, $line ) = caller 0;
+       @_ = map { ( my $temp = $_ ) =~ s/\n/\n# /g; $temp; }
+          map { defined $_ ? $_ : 'undef' } @_;
+       print STDERR "# $package:$line $PID ", join( ' ', @_ ), "\n";
+    }

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Nov 3, 2023

I have modified line length and added -b to overwrite files (in the above comment).

@svetasmirnova This is above my pay grade.
What do you think?

@svetasmirnova
Copy link
Collaborator

@szepeviktor I think it does not make sense to format code just in sake to make it compatible with perltidy. Let's have only 3 spaces in the config and don't do other formatting. We can always add additional configuration rules into .editorconfig later.

@szepeviktor szepeviktor marked this pull request as ready for review November 6, 2023 10:56
@szepeviktor
Copy link
Contributor Author

Done.

@svetasmirnova svetasmirnova merged commit a15207e into percona:3.x Nov 6, 2023
4 checks passed
@szepeviktor szepeviktor deleted the ec-new branch November 6, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants