Skip to content

Commit

Permalink
Add support for cfsqltype custom fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfreitag committed Oct 28, 2022
1 parent c9dd5bc commit 5b3d4ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name":"fixinator",
"version":"3.0.1",
"version":"3.0.2",
"author":"Foundeo Inc.",
"location":"foundeo/fixinator#v3.0.1",
"location":"foundeo/fixinator#v3.0.2",
"homepage":"https://fixinator.app/",
"documentation":"https://github.com/foundeo/fixinator/wiki",
"repository":{
Expand Down
21 changes: 19 additions & 2 deletions commands/fixinator.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,14 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
print.greyLine("Possible Fixes:");
local.fixIndex = 0;
local.fixOptions = "";
local.queryparamFix = 0;
for (local.fix in local.i.fixes) {
local.fixIndex++;
local.fixOptions = listAppend(local.fixOptions, local.fixIndex);
print.greyLine(" "&local.fixIndex&") "&local.fix.title & ": " & trim(local.fix.fixCode) );
if ( findNoCase('cfsqltype="cf_sql_varchar"', local.fix.fixCode) ) {
local.queryparamFix = local.fixIndex;
}
}
if (arguments.autofix == "prompt") {
print.toConsole();
Expand All @@ -548,12 +552,25 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
if (arrayLen(local.i.fixes) == 1) {
local.fixOptions = "1";
}
local.fix = ask(message="Do you want to fix this? Enter [#local.fixOptions#] or no: ");

if (local.queryparamFix == 0) {
local.fix = ask(message="Do you want to fix this? Enter [#local.fixOptions#] or no: ");
} else {
local.fix = ask(message="Do you want to fix this? Enter [#local.fixOptions#] or cf_sql_whatever or no: ");
}




if (isNumeric(local.fix) && local.fix >= 1 && local.fix <= arrayLen(local.i.fixes)) {
toFix.append({"fix":local.i.fixes[local.fix], "issue":local.i});
}
} else if (len(local.fix) && !isNumeric(local.fix) && local.queryparamFix != 0 && !isBoolean(local.fix)) {
//fixing with a custom cfsqltype
local.customFix = duplicate( local.i.fixes[local.queryparamFix] );
local.customFix.fixCode = replaceNoCase(local.customFix.fixCode, 'cfsqltype="cf_sql_varchar"', 'cfsqltype="#local.fix#"');
arrayAppend(local.i.fixes, local.customFix);
toFix.append({"fix":local.customFix, "issue":local.i});
}

} else if (arguments.autofix == "auto" || arguments.autofix == "automatic") {
toFix.append({"fix":local.i.fixes[1], "issue":local.i});
Expand Down

0 comments on commit 5b3d4ff

Please sign in to comment.