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

Have code formatting guideline #319

Closed
4 tasks done
ldidry opened this issue May 23, 2018 · 10 comments
Closed
4 tasks done

Have code formatting guideline #319

ldidry opened this issue May 23, 2018 · 10 comments

Comments

@ldidry
Copy link
Contributor

ldidry commented May 23, 2018

Discussion will happen on [email protected] mainling list.

Right now, we have minimal vim modelines:

  • indent with 4 spaces, no tabs

But there is a lot of other coding style stuff that could (should) be discussed, in order to have a coherent coding style in all codebase, like:

  • max line width
  • to put brace on the same line than the if (while, for, etc)
  • etc

To close this issue, we need to:

@ldidry
Copy link
Contributor Author

ldidry commented May 24, 2018

In fact, there is already a perltidyrc in https://github.com/sympa-community/sympa/blob/sympa-6.2/doc/dot.perltidyrc.

Let's use it as the base of the coding style we want.

ldidry added a commit that referenced this issue May 24, 2018
- Add cpanfile, specifying dependencies for running the xt tests
  (authors tests, not installation tests)
@ikedas
Copy link
Member

ikedas commented May 24, 2018

Hi @ldidry,

Basically, I think you’d be better to create your fork of master repo, create a branch and submit PR to propose changes. (It is not the rule: Currently we have no consensus about branching/forking, but I feel it is better in many cases). See GitHub Help for details. Sorry for unnecessary comment.

Besides, I’ve not yet had confidence to force a style to coders. Because:

  • If we decided to reformat sources by perltidy-ing regularly, test might not be required.
  • As far as I know, formatting behavior of Perl::Tidy changed release by release (please check results with some versions of perltidy). Even if coders reformatted their changes by themselves, they might not be accepted by the test.

Additional comment:
Coding style may include something not covered by reformatting. For example,

  • Naming rules: Symbols including names of packages, variables, methods, and built-in variables (either to use short or long).
  • Qualification of symbols: Either to use exported names or not (if not, always use qualified names for symbols in external modules).
  • Required and allowed pragma.

Regards,
— Soji

ldidry added a commit that referenced this issue May 24, 2018
- Add cpanfile, specifying dependencies for running the xt tests
  (authors tests, not installation tests)
ldidry added a commit that referenced this issue May 24, 2018
- Add cpanfile, specifying dependencies for running the xt tests
  (authors tests, not installation tests)
@ldidry
Copy link
Contributor Author

ldidry commented May 25, 2018

If we decided to reformat sources by perltidy-ing regularly, test might not be required.

Well, in fact, we might: having this test allows to use it in Travis, so that you can check that a PR is perltidy-compliant. It's not a non-acceptance flag for the PR, of course, but by seeing this, we would be able to fix the tidying right after we accept the PR

As far as I know, formatting behavior of Perl::Tidy changed release by release (please check results with some versions of perltidy). Even if coders reformatted their changes by themselves, they might not be accepted by the test.

As I created a cpanfile to install dev modules (for Test::PerlTidy at first, then I saw another module for another test), we could enforce the version of PerlTidy when installing it to hack on Sympa, so every Sympa developper would (normally) use the same version and have the same behavior

Coding style may include something not covered by reformatting. For example,

You're absolutely right. What do you think about I rename this issue to "Have code formatting guideline" and create an issue that:

  • is named "Have coding style guideline" (kind of a meta-issue)
  • references this issue
  • talks about the other code style things (pragmas, naming rules, etc.) (or maybe that point could be a new issue, referenced in the meta-issue)

@ikedas
Copy link
Member

ikedas commented May 26, 2018

If we decided to reformat sources by perltidy-ing regularly, test might not be required.

Well, in fact, we might: having this test allows to use it in Travis, so that you can check that a PR is perltidy-compliant. It's not a non-acceptance flag for the PR, of course, but by seeing this, we would be able to fix the tidying right after we accept the PR

As far as I know, formatting behavior of Perl::Tidy changed release by release (please check results with some versions of perltidy). Even if coders reformatted their changes by themselves, they might not be accepted by the test.

As I created a cpanfile to install dev modules (for Test::PerlTidy at first, then I saw another module for another test), we could enforce the version of PerlTidy when installing it to hack on Sympa, so every Sympa developper would (normally) use the same version and have the same behavior

I understood. I agree to implementing perltidy test and see what will happen.

Coding style may include something not covered by reformatting. For example,

You're absolutely right. What do you think about I rename this issue to "Have code formatting guideline" and create an issue that:

  • is named "Have coding style guideline" (kind of a meta-issue)
  • references this issue
  • talks about the other code style things (pragmas, naming rules, etc.) (or maybe that point could be a new issue, referenced in the meta-issue)

I agree too.

@ldidry ldidry changed the title Have coding style guideline (and translate them in .perltidyrc) Have code formatting guideline May 26, 2018
@ldidry
Copy link
Contributor Author

ldidry commented May 26, 2018

  • Issue renamed
  • Meta issue created (Have coding style guideline #325)
  • Perl::Tidy exact version enforced in cpanfile (I choose the 20180220 version, since it was the version I have, but I don't care if somebody prefers an other version)
  • I added the test on Travis (I tested that before in an other branch, and now I will delete that old branch)

There is a PR waiting for all the current work to be merged into 6.2.x branch: #322

About the Travis test: should we let it in Travis or comment it, waiting for us to tidy up all files before re-enabling it? It now complains a lot (of course) and so isn't that useful. It will be useful when it will complain on introducing new untidy code. What do you think?

@ikedas
Copy link
Member

ikedas commented May 26, 2018

One more comment.

I concepted that documents on sympa-community.github.io will be a "documentation set" for users, and documentaion for developers would be on separate place (in its nature, it will tend to fluid and more or less inconsistent). How about using wiki built in GitHub for documentation about development?

@ldidry
Copy link
Contributor Author

ldidry commented May 26, 2018

I think it would a good thing, yes 🙂

@ldidry
Copy link
Contributor Author

ldidry commented May 26, 2018

@ikedas
Copy link
Member

ikedas commented May 26, 2018

Thanks. I'll let sympa-developpers people know.

ikedas added a commit that referenced this issue May 31, 2018
@ikedas
Copy link
Member

ikedas commented Jul 1, 2021

I see this issue may be closed now: The last task may be taken over to the new issue.

@ldidry ldidry closed this as completed Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants