Skip to content

add rangeLimit to JinjavaConfig (1000 by default)#658

Merged
boulter merged 2 commits into
HubSpot:masterfrom
ylacaute:add-range-limit-config
Apr 29, 2021
Merged

add rangeLimit to JinjavaConfig (1000 by default)#658
boulter merged 2 commits into
HubSpot:masterfrom
ylacaute:add-range-limit-config

Conversation

@ylacaute

Copy link
Copy Markdown
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

@boulter boulter left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.",

)
public static List<Integer> range(Object arg1, Object... args) {
int rangeLimit = requireNonNull(
JinjavaInterpreter.getCurrent(),

Copy link
Copy Markdown
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
Copy Markdown
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.

@ylacaute ylacaute force-pushed the add-range-limit-config branch from 27cf68c to 53cf9c1 Compare April 29, 2021 15:28

@boulter boulter left a comment

Copy link
Copy Markdown
Contributor

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