juspay / hyperswitch-control-center

Open sourced control center for managing Hyperswitch - an open sourced payment switch.
https://hyperswitch.io/
Apache License 2.0
33 stars 27 forks source link

Remove Dead Code #108

Open jainlokesh318 opened 11 months ago

jainlokesh318 commented 11 months ago

There are patches of code in the repo which are not used anymore, they can be removed. Rescript analyzer can be used to detect such code.

shubham0804 commented 11 months ago

@jainlokesh318 I'll work on this

shubham0804 commented 11 months ago

@jainlokesh318 I have a few questions regarding this 1) There are some components/screens that are not being used currently such as src/components/DistributionDonut, src/components/formOtpInput.res, etc. Should I go ahead and delete them if they will not be required in the future? 2) Some properties of types are not currently being used such as source & value in src/components/SingleStats/SingleStatEntity.res, etc. Should I remove them if they might not be used in the future? 3) Parameters of some functions are provided with default values but everywhere that the function is being called, a value is being provided for the parameter. The analyzer throws an error in such cases. Should I remove the default value? Ex: filterNull parameter in chartDataMaker function in src/components/CustomCharts/LineChartUtils.res

PritishBudhiraja commented 11 months ago

Hey @shubham0804 ,

  1. You can remove the files that are not being used. They won't be required in the near future. If we need them later, we can always revert to the previous commit to retrieve those changes. For now, feel free to remove them.
  2. Just check these values. Although we may not be actively reading them, there could be instances where we need to send them in the API body.
  3. Please review and remove any default values. After doing so, ensure that the code compiles correctly. If a parameter value is consistently passed, it's acceptable to remove its default value.
shubham0804 commented 11 months ago

I have a few further queries: 1) The Analyzer is giving false positives for a lot of context files. For example ./src/context/AddAttributesContext.res. Should I add @live decorator to them? 2) The analyzer is showing a lot of warnings regarding the HSMixPanel screen. One case is: In Button.res it says that optional argument contextName of function hyperswitchMixPanel is always supplied (1 calls). But on removing the default argument of empty string of actionName from HSMixPanel.useSendEvent the warning is removed. But then it is found that actionName parameter is not passed when calling HSMixPanel.useSendEvent from FormRenderer.res. Could this be a false positive from the analyzer or am I missing something here? 3) Is the objective to remove all dead code from the project and eventually run the analyzer in CI or to remove most of the dead code?