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

add rangeLimit to JinjavaConfig (1000 by default) #658

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

ylacaute
Copy link
Contributor

Changes:

  • we need a JinjavaInterpreter instance to execute range function because we now retrieve the rangeLimit from the configuration instead of an hardcoded value
  • default range limit is still 1000 to avoid any breaking change
  • add 2 units test and update an existing one
  • mvn prettier:write ok

Copy link
Contributor

@boulter boulter left a comment

Choose a reason for hiding this comment

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

A few comments, otherwise looks good. Thanks!

@@ -1,6 +1,8 @@
package com.hubspot.jinjava.lib.fn;

import static com.hubspot.jinjava.interpret.JinjavaInterpreter.getCurrent;
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for the static import here? It's only used once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I remove it

RANGE_LIMIT +
" values.",
DEFAULT_RANGE_LIMIT +
" values by default, but this integer value is configurable.",
Copy link
Contributor

Choose a reason for hiding this comment

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

it is configurable, but not by the user which is who this documentation is targeted to.

Suggested change
" values by default, but this integer value is configurable.",
" values.",

params = {
@JinjavaParam(value = "start", type = "number", defaultValue = "0"),
@JinjavaParam(value = "end", type = "number"),
@JinjavaParam(value = "step", type = "number", defaultValue = "1")
}
)
public static List<Integer> range(Object arg1, Object... args) {
int rangeLimit = requireNonNull(
JinjavaInterpreter.getCurrent(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's only possible for this to be null in tests if you forget to push an interpreter onto the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remove it, I just don't like when my IDE is screaming at me when something can be null.

Copy link
Contributor

@boulter boulter left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

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.

2 participants