GithubHelp home page GithubHelp logo

Comments (8)

mkr-plse avatar mkr-plse commented on May 20, 2024

In the properties file, if you include your toggle method in the treatedMethods, then depending on the input to Piranha (treated/control), the then or else branch will be kept.

from piranha.

pranavsb avatar pranavsb commented on May 20, 2024

Hi!
I put all possibilities in piranha.properties
treatedMethods=isToggleEnabled,MockToggle.isToggleEnabled,MockToggle

but it doesn't work.

But I know piranha is configured correctly because dummy branches if (true) are getting removed.

Update:
Here are my piranha args, in case it helps
<arg>-Xplugin:ErrorProne -Xep:Piranha:WARN -XepPatchChecks:Piranha -XepPatchLocation:IN_PLACE -XepOpt:Piranha:FlagName=PIRANHA_PLACEHOLDER -XepOpt:Piranha:IsTreated=true -XepOpt:Piranha:Config=piranha/config/piranha.properties</arg>

from piranha.

mkr-plse avatar mkr-plse commented on May 20, 2024

Ah, I see the problem. There is no flagname for these APIs. You will need to modify the code for the no flag name case.

A broader fix for this is discussed here and here. A PR contribution for this will be appreciated.

from piranha.

pranavsb avatar pranavsb commented on May 20, 2024

I got it working by adding a mit.getArguments().size() == 0 check to getXPAPI, will raise a PR soon.

I'm wondering if it makes sense to extend this so that it checks the invocation to make sure its the correct toggle class and not just match by method name.

Something like this:
piranha.properties
treatedMethods=MockToggle1.isEnabled

Application.java

if (MockToggle1.isEnabled() {
    // this if should be removed
}
...
if (MockToggle2.isEnabled()) {
   // this one should not be removed
}

from piranha.

mkr-plse avatar mkr-plse commented on May 20, 2024

Instead of an interim fix, I suggest creating a json properties file with the following attributes:

  1. method name
  2. argument index (0, 1, .. or don't care)
  3. return type (boolean, void, ..)
  4. receiver type (MockToggle1, MockToggle2, ...)
  5. flag type (treated, control)

Processing these attributes as part of updateConfig and checking for it in getXPAPI will be ideal. We can then get rid of the piranha.properties file.

from piranha.

pranavsb avatar pranavsb commented on May 20, 2024

Ah, I see what you mean. I'll try that.

from piranha.

pranavsb avatar pranavsb commented on May 20, 2024

This is the properties.json structure I'm planning, let me know if I've missed something.

{
  "linkURL": "<provide_your_url>",
  "annotations": "",
  "piranhaMethodProperties":
    [
      {
        "methodName": "isToggleEnabled",
        "argumentIndex": null, //0,1, -1 for dont care
        "returnType": null, // boolean void etc
        "receiverType": null, // how to determine? null for dont care?
        "flagType": null // treated, control, empty, what abt treatmentGroup?
      },
      {
        "methodName": "isFlagDisabled",
        "argumentIndex": null,
        "returnType": null,
        "receiverType": null,
        "flagType": null
      },
      {
        "methodName": null,
        "argumentIndex": null,
        "returnType": null,
        "receiverType": null,
        "flagType": null
      }
    ]
}

from piranha.

lazaroclapp avatar lazaroclapp commented on May 20, 2024

Closed by #39 ! (thanks again, @pranavsb )

from piranha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.