[tor-bugs] #26184 [Applications/Tor Browser]: Think about using `const` as much as possible in Torbutton code

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Nov 14 23:42:25 UTC 2019


#26184: Think about using `const` as much as possible in Torbutton code
--------------------------------------+--------------------------
 Reporter:  gk                        |          Owner:  tbb-team
     Type:  task                      |         Status:  new
 Priority:  Medium                    |      Milestone:
Component:  Applications/Tor Browser  |        Version:
 Severity:  Normal                    |     Resolution:
 Keywords:  tbb-torbutton             |  Actual Points:
Parent ID:                            |         Points:
 Reviewer:                            |        Sponsor:
--------------------------------------+--------------------------

Comment (by pospeselr):

 For me, defaulting to const where it makes sense (ie not for obviously
 mutable variables like iterators) reduces the cognitive load during
 development and when re-visiting code later. Seeing that something is
 marked const lets me know that when the reference is used it is pointing
 to the same object throughout the block. I also appreciate the
 runtime/build errors when trying to reassign a const variable, especially
 given that JS is not strongly typed.

 My general view on these types of things is that the earlier in the
 pipelinee I get an error the better. Using const helps protect me from a
 certain class of 'whoops overwrote the reference' bugs, so I'll probably
 be using it where I can.

 Going forward I'd be in favor of preferring const everywhere in new code
 in Tor Browser.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/26184#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list