Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Trailing Comma in the Dart File. #735

Closed
StrangeNoob opened this issue Apr 26, 2021 · 10 comments · Fixed by #752
Closed

Adding Trailing Comma in the Dart File. #735

StrangeNoob opened this issue Apr 26, 2021 · 10 comments · Fixed by #752
Assignees

Comments

@StrangeNoob
Copy link
Contributor

StrangeNoob commented Apr 26, 2021

Issue Description
As we are in refactor mode, Adding trailing commas will increase the readability of the code. It will help us auto-format the code and auto-comment the ending widget.

Before After
Without Trailing Commas With Trailing Commas

Pros:

  1. Makes the code more readable
  2. With Bracket colorizer, figuring out the widget and all will be easy.
  3. Helps to auto-format the code and auto-comment about the ending widget.

Cons:

  1. As we have line restriction, It may be a problem as it increase the line. We can do something about this @Sagar2366, @palisadoes and @DeltaHarbinger.

Other Information
Instead of using print() to debug and view the output, the use of debugPrint() will be better than it won't show in the production.

Please ask mentors/maintainers to assign if you are willing to work on this issue.
I would to work on this but I have my exams starting tomorrow 😬. Let new member work on this.

@github-actions github-actions bot added the unapproved Unapproved, needs to be triaged label Apr 26, 2021
@palisadoes
Copy link
Contributor

Yes, this will increase the size of files, but the increase will be marginal in general. We need to stick with a limit. Let's see how the 300 line maximum works.

@palisadoes
Copy link
Contributor

@StrangeNoob Can this be done automatically? That will help code consistency a lot. You are proposing a manual style change that may be difficult to enforce.

@StrangeNoob
Copy link
Contributor Author

StrangeNoob commented Apr 26, 2021

I don't have an idea about automating. @sumitra19jha can we tweak analysis_options, so it can help us? Otherwise, we can look some of the plugins that might help?

@sumitra19jha
Copy link
Contributor

sumitra19jha commented Apr 26, 2021

I don't think so.
Plus adding trailing comma and then sticking with 300 lines will be tough.

@StrangeNoob
Copy link
Contributor Author

But with issue like #716 , #718 , #720 #721 may decrease the line of code significantly. Thats What I think.

@sumitra19jha
Copy link
Contributor

sumitra19jha commented Apr 26, 2021

Still, when creating a single file to handle the business logic of a particular page and organise the code, we would need:

  1. Getter
  2. Setter
  3. Query Function
  4. Mutation function
  5. then Comments

This will take space

@StrangeNoob
Copy link
Contributor Author

StrangeNoob commented May 1, 2021

@sumitra19jha Sorry to disturb you, I came across part and part_of for splitting files. Look at this https://stackoverflow.com/questions/49594307/how-to-split-dart-class-in-flutter. It might help to write large code and split them in two files.

@sumitra19jha
Copy link
Contributor

sumitra19jha commented May 1, 2021

Hi @StrangeNoob,
I hope you are good and healthy. I am not at all disturbed.
To the best of my knowledge, when we are talking about restricting code to 300 lines, we are doing so to make the codebase more organized and structured. For example, we want to shift logic into one controller file, and widgets into another file. In the case of the controller, we further want to create a separate data model file. If the widget file is long we want to take a part of it, like the tile section and use it in another file. Now if more than one file needs that tile, then duplicate code can be avoided.

So as you can see, this work is organizing the codebase. Simply splitting the dart class into two files using extend would destroy this whole purpose of refactoring. I am not saying we cannot do it, I am just saying the reason in my opinion doesn't fit our purpose.

@nayakastha
Copy link
Contributor

nayakastha commented May 2, 2021

Hey @palisadoes. I have partially worked on this issue that is changing all the print statements into debugPrint for reducing the production junk in PR #744. It would be great if I could complete this issue. Can you assign it to me?

Also, I think Flutter's formatting tool inserts these commas automatically. And won't be much of a trouble to manually add them.

@palisadoes
Copy link
Contributor

@nayakastha Done.

@palisadoes palisadoes removed the unapproved Unapproved, needs to be triaged label May 3, 2021
Ayush0Chaudhary pushed a commit to Ayush0Chaudhary/talawa that referenced this issue Mar 29, 2023
* remove token

* update marked-terminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants