Sandbox URL: https://www.drupal.org/sandbox/esolitos/2859375
Current pareview: https://pareview.sh/node/1352
Git command: git clone --branch 8.x-1.x https://git.drupal.org/sandbox/esolitos/2859375.git norwegian_id_field

This module very simply adds a field type to hold a Fødselsnummer, which is the Norwegian national ID number. The module features validation of the submitted value based on the known rules supplied by the Norwegian Tax Administration office and from Wikipedia.

CommentFileSizeAuthor
#3 case_1.png29.29 KBsugandhkhanna2

Comments

esolitos created an issue. See original summary.

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpsgitdrupalorgsandboxesolitos2859375git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

sugandhkhanna2’s picture

StatusFileSize
new29.29 KB

Hi esolitos,

pareview is containing some errors and warning. Please fix them.
pareview: https://pareview.sh/node/1352

esolitos’s picture

Status: Needs work » Needs review

Hi @sugandhkhanna2 thanks for the review, I am aware of those and I am not planing to fix them for this reasons:

  • NorwegianIdItem::isValidNorwegianID would be NorwegianIdItem::isValidNorwegianId, I think that having the ID as full capitala is much more readable than the counterpart. If this will turn out to be really a blocker.. I guess i'll change it, but I really believe that the current method signature is more readable.
  • Equals sign not aligned with surrounding assignments: If you look at the code the second reported error seems to be a false positive since the equal sign is aligned with the prev. line. Correct me if i'm wrong.
  • In README.md the lines that are longer than 80 char are actually links..
szeidler’s picture

Status: Needs review » Needs work

I installed the test and made a couple of tests with valid norwegian ids.

Automated Review

Although Pareview reports minor issues, I think it's just fine.
I also would prefer isValidNorwegianId() over isValidNorwegianID(), because the clean lower camelCase for Id's is used in Drupal 8 core. It also helps for consistency, when using Id in another context, like getIdFromSomewhere(), to clearly separate the word boundaries.

But that's just a tiny detail, so shouldn't block the application:

Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.

Manual Review

The code looks in general alright for me and makes uses DrupalAPI how it is intended.

Although it seems, that I identified an major issue in the number validation. I see a problem in

protected function isValidIndividualNum($individualNumber, $birthYear) {

When I use for example the number 311208945xx, which is a boy, who was born at 31.12.2008 fails. (You can use 2 random digits at the end, because it doesn't matter for that testcase)

The reason, that it fails, is that the function directly returns the result of the condition for a specific individual number range. As they are overlapping number ranges my case goes into

 elseif ($individualNumber >= 900 && $individualNumber <= 999) {
      return $birthYear >= 1940 && $birthYear <= 1999;
    }

and return false. Although my test individual number also works for the next elseif and would return true there.

elseif ($individualNumber >= 500 && $individualNumber <= 999) {
      return $birthYear >= 2000 && $birthYear <= 2039;
    }

Can you reproduce the error, or was I wrong with my manual testcase?

esolitos’s picture

Status: Needs work » Needs review

Thanks for the valuable feedback!

I renamed the method to isValidNorwegianId() as suggested and moved the custom validation to a Validation plugin so can be also used by other modules.
On top of that I fixed the bug reported by szeidler and also added a PHPUnit test.

Currently pareview.sh reports only details and false-positives.

Project is ready for more review!

szeidler’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for solving the logical error in the module, it validates correct now. Perfect to have that proven by tests.

From my perspective the module looks ready to go now.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution!

I updated your account so you can opt into security advisory coverage now.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thank you, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks go the dedicated reviewer(s) as well.

esolitos’s picture

Thank you!

klausi’s picture

Assigning credits.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.