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

Tech(perf): frozen string literals partout #10386

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

colinux
Copy link
Member

@colinux colinux commented Apr 28, 2024

Maintenant qu'on connait notre bonne couverture de tests, on peut être confiant sur ce genre de changements (+ canary release).

Rappels:

  • ne concerne que les string définies dans des fichiers .rb (donc pas venant de la db ou autre)
  • ne concerne pas les views
  • n'impacte pas les string qui contiennent une interpolation
  • + devant un string le définit comme mutable

Cas où des strings doivent rester mutables :

  • app/models/concerns/tags_substitution_concern.rb: parser de tags (parsby modifie l'IO)
  • dans quelques tests , soit par construction du test, soit parce-qu'on y hardcode un literal qui doit être traité comme une variable (par exemple: param d'une requête)

Dans un commit isolé j'ai supprimé du code dans Dolist::API à propos de l'envoi d'email avec des attachments, car :

  • ce code est inutilisé et on ne rentrait jamais dedans , car notre compte dolist ne permet pas l'envoi de PJ
  • ce code contenait un string qui était mutable
    J'en ai profité pour rajouter quelques tests sur cette classe qui n'en avait aucun.

Copy link

codecov bot commented Apr 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.34%. Comparing base (1750641) to head (d5baa2d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10386      +/-   ##
==========================================
- Coverage   80.79%   79.34%   -1.46%     
==========================================
  Files        1193     1058     -135     
  Lines       25139    23625    -1514     
  Branches     4526     4218     -308     
==========================================
- Hits        20312    18745    -1567     
- Misses       4827     4880      +53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

See https://github.com/jolmg/parsby/blob/534f8a95b40cd7102bb55abd2a02ef576a9198da/lib/parsby.rb#L572C11-L572C17

Trace:
IOError: not modifiable string
    # parsby-1.1.1/lib/parsby.rb:572:in `ungetc'
    # parsby-1.1.1/lib/parsby.rb:572:in `ungetc'
    # parsby-1.1.1/lib/parsby.rb:539:in `block in restore'
    # parsby-1.1.1/lib/parsby.rb:539:in `each'
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 this pull request may close these issues.

None yet

1 participant