[{"name":"Review.Fix","comment":" Tools to write automatic error fixes.\n\nWhen creating a [`Review.Rule.Error`](./Review-Rule#Error), you can provide an automatic\nfix for the error using [`Review.Rule.errorWithFix`](./Review-Rule#errorWithFix)\nor other functions that end with \"withFix\"sothattheuserdoesn'tneedtofix\ntheproblemthemselves.\n\nInthe[CLI],theusercanasktofixtheerrorsautomatically,andindoingso,\ntheywillbepresentedbyafixwhichtheycanacceptorrefuse.Ifthefixgets\nrefused,thenthenextfixableerrorwillbepresented.Otherwise,ifthefix\ngetsaccepted,thefilewillbeappliedandthefixedfilecontentgetanalyzed\nagainbythedifferentrulesintheuser'sconfiguration,andthenanotherfix\nwillbepresented.Whentherearenomorefixableerrors,theremainingerrors\nwillbereported,justlikewhentheuserdoesn'trequesterrorstobeautomatically\nfixed.\n\nInsummary,errorswillbepresentedonebyoneandtheuserwillvalidatethem.\nThe[CLI]alsoproposesanoptiontofixalltheerrors,whichapplieseachfix\nonebyoneandthenaskstheusertoconfirmthecumulatedfix.\n\n\n#Guidelines\n\nAnautomaticfix,whenapplied,shouldresolvethereportederrorcompletely.\nThismeansthatwhentheautomaticfixisapplied,theusershouldnothaveto\nthinkabouttheerroranymoreorhavetodoadditionalwork.\n\nImagineiftheuserappliesalotofautomaticfixesallatonce.Wedon'twantthemtohaveto\nrememberhavingtodosomething,otherwisewemayhavejustoffloadedalotof\nworkthattheymayforgettodo.Inthatcase,itisbetternottoprovideafix\natall,sothattheykeepareminderandthedetailsofhowtofixtheproblem.\n\nAnautomaticfixshouldresolveonlythereportederror,nottrytofixother\npotentialerrors.Byonlyfixingoneerroratatime,thefixwillbeeasierfor\ntheusertodigestandunderstand.Thefilewillbere-reviewedwhenthefixis\napplied,andthenanothererrorcanfixthatone.\n\n\n#When(not)toprovideanautomaticfix?\n\nForusers,havinganautomaticfixalwaysfeelslikeanice-to-haveandtheymay\nrequestyoutoprovidesome,buttheyarenotmandatory,andinsomecases,it\nisbetternottohaveany.\n\n\n##Reasonsnottoprovideanautomaticfix\n\n\n###Acompleteautomaticfixisnotpossible\n\nSometimes,justbygoingthroughthewholefile,youaremissingsomeofthe\ninformationneededtogeneratetherightfix.Insteadofprovidingapartialor\npotentiallyincorrectfix,itwouldbebettertoprovidemoredetails,hintsor\nsuggestions.\n\n\n###Thefixwouldresultinacompilererror\n\nAnautomaticfixshouldnotcausechangesthatwouldbreakthefileorthe\nproject.Insomecases,wecandetectthatthe[fixwillbreakthings](#Problem),\nlikeiftheresultofthefixisinvalidElmcode(asinresultinginaparsing\nerror),butultimatelywecan'tdetectthattheprojectwillstillcompileafter\nthefixisapplied.\n\nUsersarenotifiedthatanautomaticfixisavailable.Forperformancereasons,\nweonlycheckthatafixisvalidbeforepresentingittotheuserandignoreit\nifitturnsouttobeinvalid.Thismeansthattheuserwillbedisappointedor\nconfusedwhentheerrorendsupnotbeingenforced.Theonlywaywehaveto\npreventthisistowritetests,asfixesareappliedintests.\n\n\n###Theusershouldlearnaboutproblemandhowtosolveit\n\nSometimesproblemsarelearningopportunities,anditisworthhavingtheuser\nspendsometimereadingthroughthedetailsoftheerrorandtryingseveral\nalternativesinordertounderstandtheproblemandthetradeoffsofthe\nsolutions.Youcanguidethembyusinggreaterrordetails!\n\n\n##Reasonstoprovideanautomaticfix\n\nThereasonstoprovideanautomaticfixarebasicallytheoppositeofthe\nreasonsnottoprovideanautomaticfix:\n\n-Weknowhowtofixtheproblemcompletelyandaccurately\n-Thetaskismenialandtheuserwillnotlearnanythingbyfixingtheerror\nthemse