Add a new rule in coder which will sniff for e.g and i.e. (with or without the preceding '.' in the end) in comments, documentations and strings.
The literals e.g. and i.e. should be replaced with English words "for example," and "that is," respectively.

Comments

malavya created an issue. See original summary.

imalabya’s picture

apaderno’s picture

I am not sure such rule would work, since:

  • i.e. and e.g. aren't necessarily wrong
  • It's not possible to always replace them with the same phrase

It is true that many times they are over-used, and often they are used in a ungrammatical and inappropriate way, but a rule trying to fix the grammaticality of a sentence will probably not work.

quietone’s picture

I was making a change in #2939645: The sample batch finished callback function should have the fourth parameter that included the use of e.g. and decided to check the proper usage. I search the net and found conflicting examples and then searched Drupal coding standards (nothing there) and then the issue queue and found this issue. It would be very helpful to know what to do with the e.g. I am editing.

What needs to happen next here to reach a decision?

apaderno’s picture

Title: Add rule for replacing e.g. and i.e. with English words. » Add a rule for replacing e.g. and i.e. with English words

i.e. stands for that is or in other words. e.g. stands for for example.

A string which represents the elapsed time for the batch process, e.g. '1 min 30 sec'.

e.g. in that case is correct, since what follows is just an example of acceptable input. It can be replaced with for example, if you want to avoid using e.g..

xjm’s picture

I don't think we need the coder rule to offer a phpcbf fix for an automatic replacement, since that may require human language skill. I think we just need it to flag them in phpcs.