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

WINDUP-2018 Enable tattletale by default #1330

Merged
merged 7 commits into from
Sep 12, 2018
Merged

Conversation

mrizzi
Copy link
Member

@mrizzi mrizzi commented Aug 23, 2018

  • Tattletale report generation enabled by default without any need to provide option
  • deprecated --enableTattletale option with the following console warning:
WARNING: (DEPRECATED) --enableTattletale option is not necessary anymore since Tattletale report generation is enabled by default. Use only --disableTattletale option if you want to disable it.
  • added --disableTattletale option
  • check before executing analysis' execution that not both options (--enableTattletale and --disableTattletale) are provided. If that's the case the executions stops with the following message:
ERROR: Do NOT use --enableTattletale and --disableTattletale options together. Tattletale report generation is enabled by default so --enableTattletale option should be removed.
  • created new tests for different use cases (no option, only --enableTattletale, only --disableTattletale, both options)
  • this change works also in the Web UI without any needed change
  • Tattletale report: add the standard header (with tooltip, application name and paddings) we have in all the other reports (and removing the standard border the browser adds to iframes)
    screenshot from 2018-08-23 19-23-45

@mrizzi mrizzi force-pushed the WINDUP-2018 branch 2 times, most recently from 151133f to 1c9a473 Compare August 23, 2018 17:25
@mrizzi mrizzi requested a review from m-brophy August 23, 2018 17:38
@mrizzi
Copy link
Member Author

mrizzi commented Aug 24, 2018

Commit e44fc8a has the changes needed for implementing the requirements from this comment on JIRA on.

Boolean disableReport = (Boolean) event.getGraphContext().getOptionMap().get(DisableTattletaleReportOption.NAME);
Collection<String> targets = (Collection<String>) event.getGraphContext().getOptionMap().get(TargetOption.NAME);
boolean eapTarget = targets.stream().anyMatch(target -> target.startsWith("eap"));
if (eapTarget && disableReport != null && disableReport && (enableReport == null || !enableReport))
Copy link
Contributor

Choose a reason for hiding this comment

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

for a tiny bit more readability I would use Boolean.valueOf(disableReport) here and for the enableReport logic as well

@mrizzi mrizzi force-pushed the WINDUP-2018 branch 2 times, most recently from f649a37 to 8fb1e9b Compare September 6, 2018 11:02
@jonathanvila
Copy link
Member

I have to say that from the developer point of view is a bit criptic having enableOption and disableOption at the same time, and classes with a name that includes the enabling status.
I understand that is for backward compatibility, but having something proxing the external configuration to a class that only considers an option and has its enabled status could be a bit more clear.

package org.jboss.windup.tests.bootstrap.migrate;

import org.jboss.windup.bootstrap.Bootstrap;
import org.jboss.windup.rules.apps.tattletale.TattletaleRuleProvider;
Copy link
Member

Choose a reason for hiding this comment

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

it seems this import is not used

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, thanks.
Also TattletaleEnablementByDefaultTest.java seems to have some

@mrizzi mrizzi removed the request for review from m-brophy September 7, 2018 16:34

private boolean isTattleTaleReportGenerationEnabled(GraphRewrite event)
{
Boolean enableReport = (Boolean) event.getGraphContext().getOptionMap().get(EnableTattletaleReportOption.NAME);
Copy link
Member

Choose a reason for hiding this comment

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

We could convert this to :
boolean enableReport = (boolean) event.getGraphContext().getOptionMap().getOrDefault(EnableTattletaleReportOption.NAME, Boolean.FALSE);

And this way we can avoid using BooleanUtils and make it clearer.... what do you think ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm afraid this would lead to a NPE in case there's no such a key due to the unboxing done on null

Copy link
Member Author

@mrizzi mrizzi Sep 10, 2018

Choose a reason for hiding this comment

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

Ah sorry, you proposed the default version even if i don't think we should have the options default here.
Would you prefer having the boolean instead of BooleanUtils for readability?
Or, talking about code, if we prefer

Boolean disableReport = (Boolean) event.getGraphContext().getOptionMap().get(DisableTattletaleReportOption.NAME);
if (BooleanUtils.isTrue(disableReport))

or

boolean disableReport = (boolean) event.getGraphContext().getOptionMap().getOrDefault(DisableTattletaleReportOption.NAME, Boolean.FALSE);
if (disableReport)

Copy link
Member

Choose a reason for hiding this comment

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

well, a pure boolean is easier to read, and in fact if we dont have the value in the map we consider them as false, is what BooleanUtils is doing
public static boolean isTrue(Boolean bool) { if (bool == null) { return false; } else { return bool; } }

@mrizzi mrizzi merged commit 50c62cc into windup:master Sep 12, 2018
@mrizzi mrizzi deleted the WINDUP-2018 branch September 12, 2018 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants