Comments (8)
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.
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.
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.
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.
Instead of an interim fix, I suggest creating a json properties file with the following attributes:
- method name
- argument index (0, 1, .. or don't care)
- return type (boolean, void, ..)
- receiver type (MockToggle1, MockToggle2, ...)
- 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.
Ah, I see what you mean. I'll try that.
from piranha.
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.
Closed by #39 ! (thanks again, @pranavsb )
from piranha.
Related Issues (20)
- Explicit ordering for rules
- [Swift] Comma not getting cleaned properly
- Add rules for enum cleanup
- Support multiple `path_to_codebase`s
- , is used as logical and in if/guard statements in swift. Cleanup is required
- Add function scope to swift for cleanup
- Enum scope not supported in Kotlin or Java
- Report error diagnosis for not parseable tree-sitter queries
- Cannot create dummy rule from python api
- [bug] [PiranhaAgent] error thrown after applying the inferred rule to the sample before/after snippet in the doc HOT 3
- [PiranhaAgent] support for TS HOT 3
- PiranhaObjC : Can I use it in the enable modules project ? HOT 4
- Facing issue while creating binary for polygot piranha HOT 1
- Too many logs
- Make concrete syntax agnostic to trailing commas
- can we add string with double quotes in treated function HOT 6
- Do you have any plans to support OpenFeature?
- Is there anyway to add the multiple flag names in pom.xml compilerArgs HOT 1
- [WIP] Proper grammar for concrete syntax
- Test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piranha.