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

Convert ISBN10 to ISBN13 and change add to add_if_new #205

Merged
merged 14 commits into from
Oct 6, 2017
Merged

Convert ISBN10 to ISBN13 and change add to add_if_new #205

merged 14 commits into from
Oct 6, 2017

Conversation

GlazerMann
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Oct 2, 2017

Codecov Report

Merging #205 into development will increase coverage by 6.26%.
The diff coverage is 72%.

Impacted file tree graph

@@                Coverage Diff                @@
##             development     #205      +/-   ##
=================================================
+ Coverage          65.72%   71.99%   +6.26%     
- Complexity          1201     1212      +11     
=================================================
  Files                  8        8              
  Lines               2343     2278      -65     
=================================================
+ Hits                1540     1640     +100     
+ Misses               803      638     -165
Impacted Files Coverage Δ Complexity Δ
Template.php 79.65% <72%> (+0.16%) 1141 <9> (+11) ⬆️
expandFns.php 90.59% <0%> (+18.97%) 0% <0%> (ø) ⬇️
wikiFunctions.php 52.31% <0%> (+52.31%) 0% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4de50d2...8e88adb. Read the comment docs.

@ms609
Copy link
Owner

ms609 commented Oct 2, 2017

Unless there are circumstances when one might want to add an ISBN without undergoing this check, my suggestion would be to call the function once from within add_if_new, rather than each time add_if_new is called. One fewer thing to remember when adding calls in the future, it catches cases where the parameter name is now hard-coded (e.g. conversion of ID parameter), and it keeps all the handy format checks in one place.

@GlazerMann
Copy link
Collaborator Author

I will do that

@GlazerMann
Copy link
Collaborator Author

This fails the quality control because add_if_new correctly sets the "year" parameter instead of the "date" parameter.

@GlazerMann
Copy link
Collaborator Author

This is now called in add_if_new
Also several adds are now add if new
Finally called in tidy() which should fix existing ones-you can decide if that is wise

@GlazerMann GlazerMann changed the title Convert ISBN10 to ISBN13 in some places Convert ISBN10 to ISBN13 and change add to add_if_new Oct 3, 2017
@GlazerMann
Copy link
Collaborator Author

I think this is done now.

Copy link
Owner

@ms609 ms609 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small error in regexp syntax

Template.php Outdated
public function isbn10Toisbn13 ($isbn10) {
$isbn10 = trim($isbn10); // Remove leading and trailing spaces
$isbn10 = str_replace(array('—','―','–','−','‒'),'-', $isbn10); // standardize dahses : en dash, horizontal bar, em dash, minus sign, figure dash, to hyphen.
if (preg_match("/[^0123456789Xx-]/",$isbn10) === 1) return $isbn10; // Contains invalid characters
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to escape the hyphen.
"/[^0123456789Xx\-]/"
Or more concisely
"/[^0-9Xx\-]/"

For consistency I'd also suggest using ~ instead of / as the regular expression delimiter.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to add a test case too, please?

@ms609 ms609 merged commit c178680 into ms609:development Oct 6, 2017
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.

None yet

2 participants