From 4f3488c1a59978554fec9d47053fa7c08a00435b Mon Sep 17 00:00:00 2001 From: chadiii Date: Thu, 9 Feb 2023 18:41:14 +0100 Subject: [PATCH 01/17] fix js/react regex --- internal/model/language_regexes.go | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 29c810f..e9b18a7 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -22,22 +22,22 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)useFsModifications\(.+?\)`, // SDK React V2 - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*['"]?(.+?)['"]?\s*[\"\,]`, + FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v ,}]+).*[},]`, HasMultipleKeys: true, }, { FunctionRegex: `(?s)useFsFlag\(.+?\)`, // SDK React V3 - FieldRegex: `useFsFlag\(['"]?\s*(.+?)['"](?:.\s*)['"]?(.+?)['"]?\s*[\"\)]`, + FieldRegex: `useFsFlag\(['"]?\s*(.+?)['"](?:.\s*)\s*(.*?)\s*(?:\)\s+)`, HasMultipleKeys: true, }, { FunctionRegex: `(?s)\.getModifications\(.+?\].+?\)`, // SDK JS V2 - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*['"]?(.+?)['"]?\s*[\"\,]`, + FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v ,}]+).*[},]`, HasMultipleKeys: true, }, { FunctionRegex: `(?s)getFlag\(.+?\)`, // SDK JS V3 - FieldRegex: `getFlag\(['"]?\s*(.+?)['"](?:.\s*)['"]?(.+?)['"]?\s*[\"\)\,]`, + FieldRegex: `getFlag\(['"]?\s*(.+?)['"](?:.\s*)\s*(.*?)\s*(?:\)\.)`, HasMultipleKeys: true, }, }, @@ -47,7 +47,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.GetModification(String|Number|Bool|Object|Array)\(.+?\)`, // SDK GO V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\,]`, + FieldRegex: `\s*['"](.+?)['"](?:,\s*)\s*(.*?)\s*(?:,|\))`, }, }, }, @@ -56,7 +56,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.get_modification\(.+?\)`, // SDK PYTHON V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FieldRegex: `\s*['"](.+?)['"](?:,\s*)\s*(.*?)\s*(?:,|\))`, }, }, }, @@ -65,11 +65,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK JAVA V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FieldRegex: `getModification\("(.*?)",\s*(.*?)\s*(?:,|\))`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK JAVA V3 - FieldRegex: `(?s)\.getFlag\(['"](.+?)['"](?:.\s*)['"]?(.+?)['"]?\s*[\"\)\,]`, + FieldRegex: `getFlag\("(.*?)",\s*(.*?)\s*(?:,|\))`, }, }, }, @@ -77,12 +77,12 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.php$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\-\>getModification\(.+?\)`, // SDK PHP V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FunctionRegex: `(?s)\-\>getModification\(.+?\)`, // SDK PHP V1 && SDK PHP V2 + FieldRegex: `getModification\("(.*?)",\s*(.*?)\s*(?:,|\))`, }, { FunctionRegex: `(?s)\-\>getFlag\(.+?\)`, // SDK PHP V3 - FieldRegex: `(?s)\-\>getFlag\(['"](.+?)['"](?:.\s*)['"]?(.+?)['"]?\s*[\"\)\,]`, + FieldRegex: `getFlag\(['"](.+?)['"](?:.\s*)\s*(.*?)\s*(?:,|\))`, }, }, }, @@ -91,11 +91,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK ANDROID V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FieldRegex: `getModification\("(.*?)",\s*(.*?)\s*(?:,|\))`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK ANDROID V3 - FieldRegex: `(?s)\.getFlag\(['"](.+?)['"](?:.\s*)['"]?(.+?)['"]?\s*[\"\)\,]`, + FieldRegex: `getFlag\("(.*?)",\s*(.*?)\s*(?:,|\))`, }, }, }, @@ -104,11 +104,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK iOS V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?default(?:String|Double|Bool|Float|Int|Json|Array)['"]?\s*\:\s*['"]?(.+?)['"]?\s*[\"\,]`, + FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?default(?:String|Double|Bool|Float|Int|Json|Array)['"]?\s*\:\s*(.+?)\s*[\,]`, }, { FunctionRegex: `(?s)\.getFlag\(key: ['"](.+?)['"]`, // SDK iOS V3 - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*['"]?(.+?)['"]?\s*[\)]`, + FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(.+?)\s*[\)]`, }, }, }, @@ -121,7 +121,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)\s*getFlagWithKey:@.+?\]`, // SDK iOS V3 - FieldRegex: `\s*getFlagWithKey:@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\@?\s*['"]?(.+?)['"]?\s*[\]]`, + FieldRegex: `\s*getFlagWithKey:@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\@?\s*(.+?)\s*[\]]`, }, }, }, From 63cf0f77e2bf1bd0775b99872e6cb6389d803f3f Mon Sep 17 00:00:00 2001 From: chadiii Date: Thu, 9 Feb 2023 18:43:27 +0100 Subject: [PATCH 02/17] fix react regex --- internal/model/language_regexes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index e9b18a7..4b1a478 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -27,7 +27,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)useFsFlag\(.+?\)`, // SDK React V3 - FieldRegex: `useFsFlag\(['"]?\s*(.+?)['"](?:.\s*)\s*(.*?)\s*(?:\)\s+)`, + FieldRegex: `useFsFlag\(['"]?\s*(.+?)['"](?:.\s*)\s*(.*?)\s*(?:\)\s*\n)`, HasMultipleKeys: true, }, { From f22b2bdacad6ae4c1d2b4d3516529b1d485531f4 Mon Sep 17 00:00:00 2001 From: chadiii Date: Mon, 13 Feb 2023 11:00:20 +0100 Subject: [PATCH 03/17] fix js/react support , & () --- internal/model/language_regexes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 4b1a478..58fca5b 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -27,7 +27,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)useFsFlag\(.+?\)`, // SDK React V3 - FieldRegex: `useFsFlag\(['"]?\s*(.+?)['"](?:.\s*)\s*(.*?)\s*(?:\)\s*\n)`, + FieldRegex: `useFsFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, HasMultipleKeys: true, }, { @@ -37,7 +37,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)getFlag\(.+?\)`, // SDK JS V3 - FieldRegex: `getFlag\(['"]?\s*(.+?)['"](?:.\s*)\s*(.*?)\s*(?:\)\.)`, + FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, HasMultipleKeys: true, }, }, From 36e0f22096d5843d323ccd5b75218304ed2904f8 Mon Sep 17 00:00:00 2001 From: chadiii Date: Mon, 13 Feb 2023 16:48:24 +0100 Subject: [PATCH 04/17] add support for , & ) in go,py, java, php and kt --- internal/model/language_regexes.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 58fca5b..c27da72 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -47,7 +47,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.GetModification(String|Number|Bool|Object|Array)\(.+?\)`, // SDK GO V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)\s*(.*?)\s*(?:,|\))`, + FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, }, }, }, @@ -56,7 +56,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.get_modification\(.+?\)`, // SDK PYTHON V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)\s*(.*?)\s*(?:,|\))`, + FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, }, }, }, @@ -65,11 +65,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK JAVA V2 - FieldRegex: `getModification\("(.*?)",\s*(.*?)\s*(?:,|\))`, + FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK JAVA V3 - FieldRegex: `getFlag\("(.*?)",\s*(.*?)\s*(?:,|\))`, + FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, }, }, }, @@ -78,11 +78,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\-\>getModification\(.+?\)`, // SDK PHP V1 && SDK PHP V2 - FieldRegex: `getModification\("(.*?)",\s*(.*?)\s*(?:,|\))`, + FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, }, { FunctionRegex: `(?s)\-\>getFlag\(.+?\)`, // SDK PHP V3 - FieldRegex: `getFlag\(['"](.+?)['"](?:.\s*)\s*(.*?)\s*(?:,|\))`, + FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, }, }, }, @@ -91,11 +91,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK ANDROID V2 - FieldRegex: `getModification\("(.*?)",\s*(.*?)\s*(?:,|\))`, + FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK ANDROID V3 - FieldRegex: `getFlag\("(.*?)",\s*(.*?)\s*(?:,|\))`, + FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, }, }, }, From 1e56c7b72eacc664d082d3d266b838cbe3a13821 Mon Sep 17 00:00:00 2001 From: chadiii Date: Tue, 14 Feb 2023 10:53:18 +0100 Subject: [PATCH 05/17] fix regex --- internal/model/language_regexes.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index c27da72..1e3e710 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -27,7 +27,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)useFsFlag\(.+?\)`, // SDK React V3 - FieldRegex: `useFsFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `useFsFlag[(](?:\s*(["'].*['"]),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, HasMultipleKeys: true, }, { @@ -37,7 +37,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)getFlag\(.+?\)`, // SDK JS V3 - FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `getFlag[(](?:\s*(["'].*['"]),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, HasMultipleKeys: true, }, }, @@ -47,7 +47,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.GetModification(String|Number|Bool|Object|Array)\(.+?\)`, // SDK GO V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, }, }, @@ -56,7 +56,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.get_modification\(.+?\)`, // SDK PYTHON V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, }, }, @@ -65,7 +65,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK JAVA V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK JAVA V3 @@ -78,7 +78,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\-\>getModification\(.+?\)`, // SDK PHP V1 && SDK PHP V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\-\>getFlag\(.+?\)`, // SDK PHP V3 @@ -91,7 +91,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK ANDROID V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(["'](\w+)['"],\s*("[^"]*"|\d+|true|false|False|True)(?:,\s*(?:true|false|\d+|"[^"]*"))?\)`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK ANDROID V3 @@ -104,11 +104,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK iOS V2 - FieldRegex: `\s*['"](.+?)['"](?:,\s*)['"]?default(?:String|Double|Bool|Float|Int|Json|Array)['"]?\s*\:\s*(.+?)\s*[\,]`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*([]"'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(key: ['"](.+?)['"]`, // SDK iOS V3 - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(.+?)\s*[\)]`, + FieldRegex: `getFlag[(]\s*key\s*:\s*(?:\s*(".*"),\s*defaultValue\s*:\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, }, }, }, From 9ecc9a99b4bde9b86bae3bc8a3fd85329c5b3215 Mon Sep 17 00:00:00 2001 From: chadiii Date: Tue, 14 Feb 2023 11:04:27 +0100 Subject: [PATCH 06/17] fix regex --- internal/model/language_regexes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 1e3e710..4ed6868 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -104,7 +104,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK iOS V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*([]"'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(key: ['"](.+?)['"]`, // SDK iOS V3 From 495ab8fd49408013e9f9f6cb0c58422c17dca69d Mon Sep 17 00:00:00 2001 From: chadiii Date: Tue, 14 Feb 2023 11:40:55 +0100 Subject: [PATCH 07/17] update ios m regex --- internal/model/language_regexes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 4ed6868..9779b8c 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -117,11 +117,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\]\s*getModification:@.+?\]`, // SDK iOS V2 - FieldRegex: `\s*['"](.+?)['"](?:\s*)default(?:String|Double|Bool|Float|Int|Json|Array):\@?\s*(['"](.+?)['"]|YES|NO|TRUE|FALSE|true|false|\d*\.?\d+)?`, + FieldRegex: `\s*['"](.+?)['"](?:\s*)default(?:String|Double|Bool|Float|Int|Json|Array):\@?\s*(['"].+?['"]|YES|NO|TRUE|FALSE|true|false|[+-]?(?:\d*[.])?\d+)?`, }, { FunctionRegex: `(?s)\s*getFlagWithKey:@.+?\]`, // SDK iOS V3 - FieldRegex: `\s*getFlagWithKey:@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\@?\s*(.+?)\s*[\]]`, + FieldRegex: `\s*getFlagWithKey\s*:\s*\@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\s*\@?\s*(.+?)\s*[\]]`, }, }, }, From bb2d8d04d3eb645a337ffc2b9e21781660be13ad Mon Sep 17 00:00:00 2001 From: chadiii Date: Tue, 14 Feb 2023 16:33:07 +0100 Subject: [PATCH 08/17] fix regex --- internal/model/language_regexes.go | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 9779b8c..b8c47b1 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -47,7 +47,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.GetModification(String|Number|Bool|Object|Array)\(.+?\)`, // SDK GO V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.GetModification(?:String|Number|Bool|Object|Array)\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, }, }, @@ -56,7 +56,7 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.get_modification\(.+?\)`, // SDK PYTHON V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.get_modification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|True|False|\d+|"[^"]*"))?\s*\)`, }, }, }, @@ -65,11 +65,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK JAVA V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK JAVA V3 - FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(](?:\s*(["'].*["']),\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -78,11 +78,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\-\>getModification\(.+?\)`, // SDK PHP V1 && SDK PHP V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\-\>getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\-\>getFlag\(.+?\)`, // SDK PHP V3 - FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `\-\>getFlag[(](?:\s*(["'].*["']),\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -91,11 +91,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK ANDROID V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK ANDROID V3 - FieldRegex: `getFlag[(](?:\s*(".*"),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(](?:\s*(["'].*["']),\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -104,11 +104,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK iOS V2 - FieldRegex: `\w+\s*[:=][^"\n]*\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.getModification\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.getFlag\(key: ['"](.+?)['"]`, // SDK iOS V3 - FieldRegex: `getFlag[(]\s*key\s*:\s*(?:\s*(".*"),\s*defaultValue\s*:\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(]\s*key\s*:\s*(?:\s*(["'].*["']),\s*defaultValue\s*:\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -117,11 +117,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\]\s*getModification:@.+?\]`, // SDK iOS V2 - FieldRegex: `\s*['"](.+?)['"](?:\s*)default(?:String|Double|Bool|Float|Int|Json|Array):\@?\s*(['"].+?['"]|YES|NO|TRUE|FALSE|true|false|[+-]?(?:\d*[.])?\d+)?`, + FieldRegex: `getModification\s*:\s*@\s*['"](.+?)['"](?:\s*)default(?:String|Double|Bool|Float|Int|Json|Array):\@?\s*(['"].+?['"]|YES|NO|TRUE|FALSE|true|false|[+-]?(?:\d*[.])?\d+)?`, }, { FunctionRegex: `(?s)\s*getFlagWithKey:@.+?\]`, // SDK iOS V3 - FieldRegex: `\s*getFlagWithKey\s*:\s*\@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\s*\@?\s*(.+?)\s*[\]]`, + FieldRegex: `getFlagWithKey\s*:\s*\@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\s*\@?\s*(.+?)\s*[\]]`, }, }, }, @@ -130,11 +130,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.GetModification\(.+?\)`, // SDK .NET V1 - FieldRegex: `(?s)\.GetModification\(['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FieldRegex: `\.GetModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.GetFlag\(.+?\)`, // SDK .NET V3 - FieldRegex: `(?s)\.GetFlag\(['"](.+?)['"](?:.\s*)['"]?(.+?)['"]?\s*[\"\)\,]`, + FieldRegex: `\.GetFlag\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, }, }, @@ -143,11 +143,11 @@ var LanguageRegexes = []LanguageRegex{ FlagRegexes: []FlagRegex{ { FunctionRegex: `(?s)\.GetModification\(.+?\)`, // SDK .NET V1 - FieldRegex: `(?s)\.GetModification\(['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FieldRegex: `\.GetModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|True|false|False|\d+|"[^"]*"))?\s*\)`, }, { FunctionRegex: `(?s)\.GetFlag\(.+?\)`, // SDK .NET V3 - FieldRegex: `(?s)\.GetFlag\(['"](.+?)['"](?:,\s*)['"]?(.+?)['"]?\s*[\)\,]`, + FieldRegex: `\.GetFlag\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, }, }, }, From 0808ed1a16e4318912f89f7133c0d06ada386af8 Mon Sep 17 00:00:00 2001 From: chadiii Date: Tue, 14 Feb 2023 17:29:16 +0100 Subject: [PATCH 09/17] fix search method --- internal/files/search.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/files/search.go b/internal/files/search.go index 27b6a7f..d969b4f 100644 --- a/internal/files/search.go +++ b/internal/files/search.go @@ -19,7 +19,7 @@ func GetFlagType(defaultValue string) (string, string) { var flagType string = "string" var flagTypeInterface interface{} - r, _ := regexp.Compile(`[^\w#]`) + r, _ := regexp.Compile(`[^\w#\-]`) json.Unmarshal([]byte(defaultValue), &flagTypeInterface) @@ -27,8 +27,12 @@ func GetFlagType(defaultValue string) (string, string) { flagType = "unknown" } - if defaultValue[0:1] == "\"" { - defaultValue = strings.Trim(defaultValue, "\"") + if (defaultValue[0:1] == "\"" || defaultValue[0:1] == "'") && (defaultValue[len(defaultValue)-1:] == "\"" || defaultValue[len(defaultValue)-1:] == "'") { + defaultValue = strings.TrimPrefix(defaultValue, "\"") + defaultValue = strings.TrimPrefix(defaultValue, "'") + defaultValue = strings.TrimSuffix(defaultValue, "\"") + defaultValue = strings.TrimSuffix(defaultValue, "'") + flagType = "string" } @@ -136,13 +140,16 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS keyWrapper = fileContentStr[flagIndex[0]-nbCharsWrapping : flagIndex[1]+nbCharsWrapping] } + key_ := strings.Trim(key, "\"") + key_ = strings.Trim(key_, "'") + lineNumber := getLineFromPos(fileContentStr, flagIndex[0]) codeLineHighlight := getLineFromPos(code, strings.Index(code, keyWrapper)) flagType, defaultValue_ := GetFlagType(defaultValue) results = append(results, model.SearchResult{ - FlagKey: key, + FlagKey: key_, FlagDefaultValue: defaultValue_, FlagType: flagType, CodeLines: code, From ed71ac313c3148fbbcdde59272b6762d569e3936 Mon Sep 17 00:00:00 2001 From: chadiii Date: Tue, 14 Feb 2023 17:50:37 +0100 Subject: [PATCH 10/17] fix regex & remove trim for key & defaultValue --- internal/files/search.go | 10 +--------- internal/model/language_regexes.go | 12 ++++++------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/internal/files/search.go b/internal/files/search.go index d969b4f..bda5c62 100644 --- a/internal/files/search.go +++ b/internal/files/search.go @@ -28,11 +28,6 @@ func GetFlagType(defaultValue string) (string, string) { } if (defaultValue[0:1] == "\"" || defaultValue[0:1] == "'") && (defaultValue[len(defaultValue)-1:] == "\"" || defaultValue[len(defaultValue)-1:] == "'") { - defaultValue = strings.TrimPrefix(defaultValue, "\"") - defaultValue = strings.TrimPrefix(defaultValue, "'") - defaultValue = strings.TrimSuffix(defaultValue, "\"") - defaultValue = strings.TrimSuffix(defaultValue, "'") - flagType = "string" } @@ -140,16 +135,13 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS keyWrapper = fileContentStr[flagIndex[0]-nbCharsWrapping : flagIndex[1]+nbCharsWrapping] } - key_ := strings.Trim(key, "\"") - key_ = strings.Trim(key_, "'") - lineNumber := getLineFromPos(fileContentStr, flagIndex[0]) codeLineHighlight := getLineFromPos(code, strings.Index(code, keyWrapper)) flagType, defaultValue_ := GetFlagType(defaultValue) results = append(results, model.SearchResult{ - FlagKey: key_, + FlagKey: key, FlagDefaultValue: defaultValue_, FlagType: flagType, CodeLines: code, diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index b8c47b1..9f54571 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -27,7 +27,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)useFsFlag\(.+?\)`, // SDK React V3 - FieldRegex: `useFsFlag[(](?:\s*(["'].*['"]),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `useFsFlag[(](?:\s*['"](.*)['"]\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, HasMultipleKeys: true, }, { @@ -37,7 +37,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)getFlag\(.+?\)`, // SDK JS V3 - FieldRegex: `getFlag[(](?:\s*(["'].*['"]),\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, + FieldRegex: `getFlag[(](?:\s*["'](.*)["']\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, HasMultipleKeys: true, }, }, @@ -69,7 +69,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK JAVA V3 - FieldRegex: `\.getFlag[(](?:\s*(["'].*["']),\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -82,7 +82,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)\-\>getFlag\(.+?\)`, // SDK PHP V3 - FieldRegex: `\-\>getFlag[(](?:\s*(["'].*["']),\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\-\>getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -95,7 +95,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK ANDROID V3 - FieldRegex: `\.getFlag[(](?:\s*(["'].*["']),\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, @@ -108,7 +108,7 @@ var LanguageRegexes = []LanguageRegex{ }, { FunctionRegex: `(?s)\.getFlag\(key: ['"](.+?)['"]`, // SDK iOS V3 - FieldRegex: `\.getFlag[(]\s*key\s*:\s*(?:\s*(["'].*["']),\s*defaultValue\s*:\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(]\s*key\s*:\s*(?:\s*["'](.*)["']\s*,\s*defaultValue\s*:\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, }, }, }, From ab12634ba8f2af9df750cb38b3dba7a20401f6ef Mon Sep 17 00:00:00 2001 From: chadiii Date: Wed, 15 Feb 2023 15:25:34 +0100 Subject: [PATCH 11/17] mix unknown regex --- internal/files/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/files/search.go b/internal/files/search.go index bda5c62..41f7696 100644 --- a/internal/files/search.go +++ b/internal/files/search.go @@ -19,7 +19,7 @@ func GetFlagType(defaultValue string) (string, string) { var flagType string = "string" var flagTypeInterface interface{} - r, _ := regexp.Compile(`[^\w#\-]`) + r, _ := regexp.Compile(`[\{\}\[\]]`) json.Unmarshal([]byte(defaultValue), &flagTypeInterface) From c5a852f8ffab708ace3b0e96df2911aff2f81df1 Mon Sep 17 00:00:00 2001 From: chadiii Date: Wed, 15 Feb 2023 16:02:11 +0100 Subject: [PATCH 12/17] remove function regex --- internal/files/search.go | 6 +-- internal/model/language_regexes.go | 65 ++++++++----------------- internal/model/language_regexes_test.go | 3 +- 3 files changed, 23 insertions(+), 51 deletions(-) diff --git a/internal/files/search.go b/internal/files/search.go index 41f7696..24871a5 100644 --- a/internal/files/search.go +++ b/internal/files/search.go @@ -85,20 +85,18 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS // Add default regex for flags in commentaries flagRegexes = append(flagRegexes, model.FlagRegex{ - FunctionRegex: `(?s)fs:flag:(\w+)`, - FieldRegex: `fs:flag:(.+)`, + FieldRegex: `fs:flag:(.+)`, }) results := []model.SearchResult{} flagIndexes := [][]int{} for _, flagRegex := range flagRegexes { - regxp := regexp.MustCompile(flagRegex.FunctionRegex) + regxp := regexp.MustCompile(flagRegex.FieldRegex) flagLineIndexes := regxp.FindAllStringIndex(fileContentStr, -1) for _, flagLineIndex := range flagLineIndexes { submatch := fileContentStr[flagLineIndex[0]:flagLineIndex[1]] - regxp := regexp.MustCompile(flagRegex.FieldRegex) submatchIndexes := regxp.FindAllStringSubmatchIndex(submatch, -1) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 9f54571..b7fa033 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -11,7 +11,6 @@ type LanguageRegex struct { } type FlagRegex struct { - FunctionRegex string `json:"function_regex"` FieldRegex string `json:"field_regex"` HasMultipleKeys bool `json:"has_multiple_keys"` } @@ -21,24 +20,16 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.[jt]sx?$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)useFsModifications\(.+?\)`, // SDK React V2 - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v ,}]+).*[},]`, - HasMultipleKeys: true, + FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v,}]+).*[},]?`, // SDK React V2 }, { - FunctionRegex: `(?s)useFsFlag\(.+?\)`, // SDK React V3 - FieldRegex: `useFsFlag[(](?:\s*['"](.*)['"]\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, - HasMultipleKeys: true, + FieldRegex: `useFsFlag[(](?:\s*['"](.*)['"]\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, // SDK React V3 }, { - FunctionRegex: `(?s)\.getModifications\(.+?\].+?\)`, // SDK JS V2 - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v ,}]+).*[},]`, - HasMultipleKeys: true, + FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v,}]+).*[},]?`, // SDK JS V2 }, { - FunctionRegex: `(?s)getFlag\(.+?\)`, // SDK JS V3 - FieldRegex: `getFlag[(](?:\s*["'](.*)["']\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, - HasMultipleKeys: true, + FieldRegex: `getFlag[(](?:\s*["'](.*)["']\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, // SDK JS V3 }, }, }, @@ -46,8 +37,7 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.go$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.GetModification(String|Number|Bool|Object|Array)\(.+?\)`, // SDK GO V2 - FieldRegex: `\.GetModification(?:String|Number|Bool|Object|Array)\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.GetModification(?:String|Number|Bool|Object|Array)\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK GO V2 }, }, }, @@ -55,8 +45,7 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.py$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.get_modification\(.+?\)`, // SDK PYTHON V2 - FieldRegex: `\.get_modification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|True|False|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.get_modification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|True|False|\d+|"[^"]*"))?\s*\)`, // SDK PYTHON V2 }, }, }, @@ -64,12 +53,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.java$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK JAVA V2 - FieldRegex: `\.getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK JAVA V2 }, { - FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK JAVA V3 - FieldRegex: `\.getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, // SDK JAVA V3 }, }, }, @@ -77,12 +64,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.php$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\-\>getModification\(.+?\)`, // SDK PHP V1 && SDK PHP V2 - FieldRegex: `\-\>getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\-\>getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK PHP V1 && SDK PHP V2 }, { - FunctionRegex: `(?s)\-\>getFlag\(.+?\)`, // SDK PHP V3 - FieldRegex: `\-\>getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\-\>getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, // SDK PHP V3 }, }, }, @@ -90,12 +75,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.kt$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK ANDROID V2 - FieldRegex: `\.getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.getModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK ANDROID V2 }, { - FunctionRegex: `(?s)\.getFlag\(.+?\)`, // SDK ANDROID V3 - FieldRegex: `\.getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, // SDK ANDROID V3 }, }, }, @@ -103,12 +86,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.swift$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.getModification\(.+?\)`, // SDK iOS V2 - FieldRegex: `\.getModification\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.getModification\(\s*["'](\w+)['"]\s*,\s*default(?:String|Double|Float|Int|Bool|Json|Array)\s*:\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)\s*(?:,\s*activate\s*:\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK iOS V2 }, { - FunctionRegex: `(?s)\.getFlag\(key: ['"](.+?)['"]`, // SDK iOS V3 - FieldRegex: `\.getFlag[(]\s*key\s*:\s*(?:\s*["'](.*)["']\s*,\s*defaultValue\s*:\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, + FieldRegex: `\.getFlag[(]\s*key\s*:\s*(?:\s*["'](.*)["']\s*,\s*defaultValue\s*:\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, // SDK iOS V3 }, }, }, @@ -116,12 +97,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.m$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\]\s*getModification:@.+?\]`, // SDK iOS V2 - FieldRegex: `getModification\s*:\s*@\s*['"](.+?)['"](?:\s*)default(?:String|Double|Bool|Float|Int|Json|Array):\@?\s*(['"].+?['"]|YES|NO|TRUE|FALSE|true|false|[+-]?(?:\d*[.])?\d+)?`, + FieldRegex: `getModification\s*:\s*@\s*['"](.+?)['"](?:\s*)default(?:String|Double|Bool|Float|Int|Json|Array):\@?\s*(['"].+?['"]|YES|NO|TRUE|FALSE|true|false|[+-]?(?:\d*[.])?\d+)?`, // SDK iOS V2 }, { - FunctionRegex: `(?s)\s*getFlagWithKey:@.+?\]`, // SDK iOS V3 - FieldRegex: `getFlagWithKey\s*:\s*\@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\s*\@?\s*(.+?)\s*[\]]`, + FieldRegex: `getFlagWithKey\s*:\s*\@['"](.+?)['"](?:\s*)['"]?defaultValue['"]?\s*\:\s*\@?\s*(.+?)\s*[\]]`, // SDK iOS V3 }, }, }, @@ -129,12 +108,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.[fc]s$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.GetModification\(.+?\)`, // SDK .NET V1 - FieldRegex: `\.GetModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.GetModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK .NET V1 }, { - FunctionRegex: `(?s)\.GetFlag\(.+?\)`, // SDK .NET V3 - FieldRegex: `\.GetFlag\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.GetFlag\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK .NET V3 }, }, }, @@ -142,12 +119,10 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.vb$`, FlagRegexes: []FlagRegex{ { - FunctionRegex: `(?s)\.GetModification\(.+?\)`, // SDK .NET V1 - FieldRegex: `\.GetModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|True|false|False|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.GetModification\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|True|false|False|\d+|"[^"]*"))?\s*\)`, // SDK .NET V1 }, { - FunctionRegex: `(?s)\.GetFlag\(.+?\)`, // SDK .NET V3 - FieldRegex: `\.GetFlag\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, + FieldRegex: `\.GetFlag\(\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\)`, // SDK .NET V3 }, }, }, diff --git a/internal/model/language_regexes_test.go b/internal/model/language_regexes_test.go index 7c3ded4..905cb20 100644 --- a/internal/model/language_regexes_test.go +++ b/internal/model/language_regexes_test.go @@ -8,7 +8,7 @@ import ( ) func TestCustomRegex(t *testing.T) { - AddCustomRegexes(`[{"extension_regex":".tsx?","flag_regexes":[{"function_regex":"(?s)useFlagShipActivation\\(.+?\\)","field_regex":"\\s*['\"](.+?)['\"]","has_multiple_keys":true}]}]`) + AddCustomRegexes(`[{"extension_regex":".tsx?","flag_regexes":[{"field_regex":"\\s*['\"](.+?)['\"]","has_multiple_keys":true}]}]`) found := funk.Find(LanguageRegexes, func(languageRegex LanguageRegex) bool { return languageRegex.ExtensionRegex == ".tsx?" @@ -22,7 +22,6 @@ func TestCustomRegex(t *testing.T) { assert.Equal(t, ".tsx?", foundLanguageRegex.ExtensionRegex) assert.Equal(t, 1, len(foundLanguageRegex.FlagRegexes)) - assert.Equal(t, "(?s)useFlagShipActivation\\(.+?\\)", foundLanguageRegex.FlagRegexes[0].FunctionRegex) assert.Equal(t, "\\s*['\"](.+?)['\"]", foundLanguageRegex.FlagRegexes[0].FieldRegex) assert.Equal(t, true, foundLanguageRegex.FlagRegexes[0].HasMultipleKeys) } From c170b5804c99fac7e7997f6b94febc37594bb775 Mon Sep 17 00:00:00 2001 From: chadiii Date: Wed, 15 Feb 2023 16:28:02 +0100 Subject: [PATCH 13/17] fix regex --- internal/model/language_regexes.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index b7fa033..4265936 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -19,14 +19,11 @@ var LanguageRegexes = []LanguageRegex{ { ExtensionRegex: `\.[jt]sx?$`, FlagRegexes: []FlagRegex{ - { - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v,}]+).*[},]?`, // SDK React V2 - }, { FieldRegex: `useFsFlag[(](?:\s*['"](.*)['"]\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, // SDK React V3 }, { - FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v,}]+).*[},]?`, // SDK JS V2 + FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v,}]+).*[},]?`, // SDK JS V2 && SDK React V2 }, { FieldRegex: `getFlag[(](?:\s*["'](.*)["']\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, // SDK JS V3 From 6f245d25e28d363cb5b3463d3e09eac3fdabc056 Mon Sep 17 00:00:00 2001 From: chadiii Date: Wed, 15 Feb 2023 16:29:10 +0100 Subject: [PATCH 14/17] fix test --- internal/files/search_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/files/search_test.go b/internal/files/search_test.go index 79c3581..d488f73 100644 --- a/internal/files/search_test.go +++ b/internal/files/search_test.go @@ -65,14 +65,14 @@ func TestSearchFiles(t *testing.T) { {name: "btnSizeInt", lineNumber: 25, codeLineHighlight: 6}, }, }, - /* { + { filePath: "../../example/src/ios/SDK_V3/sample.swift", flags: []flag{ - {name: "btnColor", lineNumber: 9, codeLineHighlight: 5}, - {name: "displayVipFeature", lineNumber: 10, codeLineHighlight: 5}, - {name: "vipFeature", lineNumber: 11, codeLineHighlight: 5}, + {name: "btnColor", lineNumber: 9, codeLineHighlight: 6}, + {name: "displayVipFeature", lineNumber: 10, codeLineHighlight: 6}, + {name: "vipFeature", lineNumber: 11, codeLineHighlight: 6}, }, - }, */ + }, { filePath: "../../example/src/java/SDK_V2/sample.java", flags: []flag{ From 3061b17dd5711f29cdeef1000a7a4f08477efc73 Mon Sep 17 00:00:00 2001 From: chadiii Date: Wed, 15 Feb 2023 17:43:08 +0100 Subject: [PATCH 15/17] remove hasMultipleKey --- internal/files/search.go | 5 +---- internal/model/language_regexes.go | 3 +-- internal/model/language_regexes_test.go | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/files/search.go b/internal/files/search.go index 24871a5..2d11fc4 100644 --- a/internal/files/search.go +++ b/internal/files/search.go @@ -100,14 +100,11 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS submatchIndexes := regxp.FindAllStringSubmatchIndex(submatch, -1) - for k, submatchIndex := range submatchIndexes { + for _, submatchIndex := range submatchIndexes { if len(submatchIndex) < 6 { log.Printf("Did not find the flag key in file %s. Code : %s", path, submatch) continue } - if !flagRegex.HasMultipleKeys && k > 0 { - break - } flagIndexes = append(flagIndexes, []int{ flagLineIndex[0] + submatchIndex[2], diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index 4265936..cf0f4f6 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -11,8 +11,7 @@ type LanguageRegex struct { } type FlagRegex struct { - FieldRegex string `json:"field_regex"` - HasMultipleKeys bool `json:"has_multiple_keys"` + FieldRegex string `json:"field_regex"` } var LanguageRegexes = []LanguageRegex{ diff --git a/internal/model/language_regexes_test.go b/internal/model/language_regexes_test.go index 905cb20..d96ae06 100644 --- a/internal/model/language_regexes_test.go +++ b/internal/model/language_regexes_test.go @@ -8,7 +8,7 @@ import ( ) func TestCustomRegex(t *testing.T) { - AddCustomRegexes(`[{"extension_regex":".tsx?","flag_regexes":[{"field_regex":"\\s*['\"](.+?)['\"]","has_multiple_keys":true}]}]`) + AddCustomRegexes(`[{"extension_regex":".tsx?","flag_regexes":[{"field_regex":"\\s*['\"](.+?)['\"]"}]}]`) found := funk.Find(LanguageRegexes, func(languageRegex LanguageRegex) bool { return languageRegex.ExtensionRegex == ".tsx?" @@ -23,5 +23,4 @@ func TestCustomRegex(t *testing.T) { assert.Equal(t, ".tsx?", foundLanguageRegex.ExtensionRegex) assert.Equal(t, 1, len(foundLanguageRegex.FlagRegexes)) assert.Equal(t, "\\s*['\"](.+?)['\"]", foundLanguageRegex.FlagRegexes[0].FieldRegex) - assert.Equal(t, true, foundLanguageRegex.FlagRegexes[0].HasMultipleKeys) } From b011ddf6ad82ab3fd70097b1998d58b9c62d00be Mon Sep 17 00:00:00 2001 From: chadiii Date: Fri, 17 Feb 2023 18:31:26 +0100 Subject: [PATCH 16/17] fix regex --- internal/model/language_regexes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/model/language_regexes.go b/internal/model/language_regexes.go index cf0f4f6..7d34d70 100644 --- a/internal/model/language_regexes.go +++ b/internal/model/language_regexes.go @@ -19,13 +19,13 @@ var LanguageRegexes = []LanguageRegex{ ExtensionRegex: `\.[jt]sx?$`, FlagRegexes: []FlagRegex{ { - FieldRegex: `useFsFlag[(](?:\s*['"](.*)['"]\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, // SDK React V3 + FieldRegex: `useFsFlag[(](?:\s*['"](.*)['"]\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, // SDK React V3 }, { FieldRegex: `['"]?key['"]?\s*\:\s*['"](.+?)['"](?:.*\s*)['"]?defaultValue['"]?\s*\:\s*(['"].*['"]|[^\r\n\t\f\v,}]+).*[},]?`, // SDK JS V2 && SDK React V2 }, { - FieldRegex: `getFlag[(](?:\s*["'](.*)["']\s*,\s*(".*\s*[^"]*"|[^)]*))\s*[)]`, // SDK JS V3 + FieldRegex: `getFlag[(](?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)]`, // SDK JS V3 }, }, }, From 57777e697715f4a927260065c9e2e399529945b2 Mon Sep 17 00:00:00 2001 From: chadiii Date: Fri, 17 Feb 2023 19:13:50 +0100 Subject: [PATCH 17/17] make defaultValue Optional --- internal/files/search.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/files/search.go b/internal/files/search.go index 2d11fc4..2487182 100644 --- a/internal/files/search.go +++ b/internal/files/search.go @@ -101,11 +101,20 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS submatchIndexes := regxp.FindAllStringSubmatchIndex(submatch, -1) for _, submatchIndex := range submatchIndexes { - if len(submatchIndex) < 6 { + if len(submatchIndex) < 3 { log.Printf("Did not find the flag key in file %s. Code : %s", path, submatch) continue } + if len(submatchIndex) < 6 { + log.Printf("Did not find the flag default value in file %s. Code : %s", path, submatch) + flagIndexes = append(flagIndexes, []int{ + flagLineIndex[0] + submatchIndex[2], + flagLineIndex[0] + submatchIndex[3], + }) + continue + } + flagIndexes = append(flagIndexes, []int{ flagLineIndex[0] + submatchIndex[2], flagLineIndex[0] + submatchIndex[3], @@ -118,11 +127,18 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS for _, flagIndex := range flagIndexes { // Extract the code with a certain number of lines + defaultValue_ := "" + flagType := "unknown" firstLineIndex := getSurroundingLineIndex(fileContentStr, flagIndex[0], true, cfg.NbLineCodeEdges) lastLineIndex := getSurroundingLineIndex(fileContentStr, flagIndex[1], false, cfg.NbLineCodeEdges) code := fileContentStr[firstLineIndex:lastLineIndex] key := fileContentStr[flagIndex[0]:flagIndex[1]] - defaultValue := fileContentStr[flagIndex[2]:flagIndex[3]] + + if len(flagIndex) >= 3 { + defaultValue := fileContentStr[flagIndex[2]:flagIndex[3]] + flagType, defaultValue_ = GetFlagType(defaultValue) + } + // Better value wrapper for code highlighting (5 chars wrapping) keyWrapper := key nbCharsWrapping := 5 @@ -133,8 +149,6 @@ func SearchFiles(cfg *config.Config, path string, resultChannel chan model.FileS lineNumber := getLineFromPos(fileContentStr, flagIndex[0]) codeLineHighlight := getLineFromPos(code, strings.Index(code, keyWrapper)) - flagType, defaultValue_ := GetFlagType(defaultValue) - results = append(results, model.SearchResult{ FlagKey: key, FlagDefaultValue: defaultValue_,