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

Followup to 2663 Regexformatter #3096

Merged
merged 10 commits into from
Aug 16, 2017

Conversation

snisnisniksonah
Copy link
Contributor

The Regexformatter now handles protected groups correctly. This is a followup to #2663. There, the regex modifier was introduced and a minor issue with shorttitle was fixes

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 10, 2017
Optional<Formatter> formatter;

if (modifier.matches("regex.*")) {
String regex = modifier.substring(5);
Copy link
Member

Choose a reason for hiding this comment

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

please define this magic number somewhere as constant

public static void setRegex(String rex) {
// formatting is like ("exp1","exp2"), we want to remove (" and ")
String rexToSet = rex;
rexToSet = rexToSet.substring(2, rexToSet.length() - 2);
Copy link
Member

Choose a reason for hiding this comment

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

please define this magic number as constant with a useful name, so it is clear what it does

@@ -950,6 +952,8 @@ Reference_library=Referencelibrary

Refine_supergroup\:_When_selected,_view_entries_contained_in_both_this_group_and_its_supergroup=Undergruppe\:_Vis_poster_indeholdt_både_i_denne_gruppe_og_gruppe_over

Regex=
Copy link
Member

Choose a reason for hiding this comment

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

Regex is the same as regular expression, I would reuse that existing translation

@Siedlerchr Siedlerchr changed the title Followup to 2663 Followup to 2663 Regexformatter Aug 11, 2017
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 11, 2017
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Minor comments regarding the constants. Then it is good to go.

@@ -65,6 +65,8 @@

public static final List<Formatter> ALL = new ArrayList<>();

private static final int LENGTH_OF_REGEX_PREFIX = 5;
Copy link
Member

Choose a reason for hiding this comment

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

Can 5 be replaced by `"regex".length()``?

@@ -87,7 +90,7 @@ public String getExampleInput() {
public static void setRegex(String rex) {
// formatting is like ("exp1","exp2"), we want to remove (" and ")
String rexToSet = rex;
rexToSet = rexToSet.substring(2, rexToSet.length() - 2);
rexToSet = rexToSet.substring(REMOVE_OUTER_QUOTES, rexToSet.length() - REMOVE_OUTER_QUOTES);
Copy link
Member

Choose a reason for hiding this comment

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

I would replace the first REMOVE_OUTER_QUOTES by "\"(".length() and the second one by ")\"".length(). Maybe as two variables LENGTH_OF_QUOTE_AND_OPENING_BRACE and LENGTH_OF_CLOSING_BRACE_AND_QUOTE.

@LinusDietz LinusDietz merged commit d07d881 into JabRef:master Aug 16, 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.

5 participants