Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Replacing magic numbers in the code by settings

Open vibl opened this issue 4 years ago • 9 comments

There are a few "magic numbers" in the code, such as in https://github.com/RocketChat/Rocket.Chat/blob/a1c41a16c550968761dd0be84673318e7bc63b10/app/lib/server/functions/saveUser.js#L231

In this example, is there a reason why 260 has not been replaced by something like settings.get('Accounts_MaxBioLength')? (With the corresponding setting added to app/lib/server/startup/settings.ts).

vibl avatar Mar 27 '22 14:03 vibl

Hello, can I work on this Issue?

has12zen avatar Apr 05 '22 10:04 has12zen

@vibl Can You Check the changes and give your feedback?

has12zen avatar Apr 05 '22 12:04 has12zen

Hi, I have made some changes in the code according to the request. Can someone please do my PR review? I am just a beginner in making PR's.

aakash-gitdev avatar Apr 19 '22 07:04 aakash-gitdev

Hello! So, as I commented here, generally adding settings for this kind of stuff isn't a good idea. It adds little value and unnecessary complexity for maintaining it afterwards.

A better option for it would be to add a const with a descriptive name so we know what the number means.

gabriellsh avatar Apr 19 '22 14:04 gabriellsh

Being able to change these settings is quite valuable for some use cases. I'm using Rocket.chat for a community where people don't necessarily know each other and we definitely need the Bio field to be longer.

vibl avatar Apr 19 '22 15:04 vibl

Hey, I had not seen your last comment. This issue was closed automatically due to the merge of the foremetioned PR.

I think we could consider just making the field bigger by default then. I really see no problem in having a few more characters in this field. What do you think?

gabriellsh avatar Apr 27 '22 14:04 gabriellsh

Ok

vibl avatar Apr 28 '22 14:04 vibl

Hey guys, so the solution in this case is to increase the number of characters in MAX_BIO_LENGTH ?

If this is the solution, what's the ideal amount of characters?

RcleydsonR avatar Jun 28 '22 18:06 RcleydsonR

Hey, I had not seen your last comment. This issue was closed automatically due to the merge of the foremetioned PR.

I think we could consider just making the field bigger by default then. I really see no problem in having a few more characters in this field. What do you think?

Hi, I am a beginner and if this issue is still open I would like to work on it?

kanhaiya04 avatar Aug 04 '22 20:08 kanhaiya04

Is this issue still available?

sameer920 avatar Feb 05 '23 10:02 sameer920

Hey!! I want to work on this issue. I'm new here so I'm really excited to start contributing. Please assign it to me.

Gua00va avatar Feb 15 '23 18:02 Gua00va

Hi @dudanogueira! I think adding a few consts instead of adding these values in the settings.ts file is a more elegant solution. Can I go ahead and work on this approach?

faraz16iqbal avatar Mar 06 '23 07:03 faraz16iqbal

Closing this one, already fixed here: #25231

dougfabris avatar Apr 20 '23 20:04 dougfabris