Opened 7 years ago

Last modified 23 months ago

#6313 new project

Many of Tor's complex functions should be refactored

Reported by: nickm Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version: Tor: 0.2.7
Severity: Normal Keywords: tor-relay, intro, tor-tests-coverage, tor-tests-unit intro
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor: SponsorS-can

Description

See some discussion on #6177.

I'm attaching a list of the most complex functions in Tor (by cyclomatic complexity).

Possibly cyclomatic-complexity-per-line would be another good thing to look at.

Child Tickets

TicketStatusOwnerSummaryComponent
#6177closedRefactor rend_service_introduce()Core Tor/Tor
#22408newRefactor functions over 300 lines long.Core Tor/Tor

Attachments (2)

top_offenders.txt (4.0 KB) - added by nickm 6 years ago.
cyclomatic complexity >= 20
longest-functions.txt (6.2 KB) - added by nickm 23 months ago.
functions with >= 100 lines

Download all attachments as: .zip

Change History (31)

comment:1 Changed 7 years ago by nickm

Keywords: tor-relay added

comment:2 Changed 7 years ago by nickm

Component: Tor RelayTor

comment:3 Changed 6 years ago by nickm

Milestone: Tor: 0.2.4.x-finalTor: 0.2.5.x-final

Bumping to 0.2.5, along with other remaining noncritical enhancements.

comment:4 Changed 6 years ago by nickm

I've regenerated the cyclomatic complexity table, taking the top 100 offenders.

Changed 6 years ago by nickm

Attachment: top_offenders.txt added

cyclomatic complexity >= 20

comment:5 Changed 5 years ago by nickm

Milestone: Tor: 0.2.5.x-finalTor: 0.2.6.x-final

comment:6 Changed 5 years ago by nickm

Milestone: Tor: 0.2.6.x-finalTor: 0.2.???

We should clean out these abominations as we go, but refactoring all of them from Tor in a single release cycle is likely a bit much.

comment:7 Changed 4 years ago by nickm

Milestone: Tor: 0.2.???Tor: 0.2.7.x-final

These may be worth looking at for 0.2.7.

comment:8 Changed 4 years ago by nickm

Status: newassigned

comment:9 Changed 4 years ago by nickm

Keywords: 027-triaged-1-in added

Marking some tickets as triaged-in for 0.2.7 based on early triage

comment:10 Changed 4 years ago by isabela

Keywords: SponsorS added
Points: large
Version: Tor: 0.2.7

comment:11 Changed 4 years ago by nickm

Milestone: Tor: 0.2.7.x-finalTor: 0.2.8.x-final

comment:12 Changed 4 years ago by nickm

Keywords: SponsorS removed
Sponsor: SponsorS

Bulk-replace SponsorS keyword with SponsorS sponsor field in Tor component.

comment:13 Changed 3 years ago by nickm

Milestone: Tor: 0.2.8.x-finalTor: 0.2.9.x-final
Owner: set to nickm

It is impossible that we will fix all 234 currently open 028 tickets before 028 releases. Time to move some out. This is my first pass through the accepted and assigned tickets in my name, looking for things to move to 0.2.9.

comment:14 Changed 3 years ago by nickm

Keywords: intro added

comment:15 Changed 3 years ago by nickm

Owner: nickm deleted

comment:16 Changed 3 years ago by nickm

Severity: Normal
Type: enhancementproject

comment:17 Changed 3 years ago by nickm

Sponsor: SponsorSSponsorS-can

comment:18 Changed 3 years ago by nickm

Owner: set to nickm

comment:19 Changed 3 years ago by nickm

Keywords: tor-tests-coverage tor-tests-unit added

comment:20 Changed 3 years ago by isabela

Points: large6

comment:21 Changed 3 years ago by nickm

Milestone: Tor: 0.2.9.x-final
Parent ID: #17289

comment:22 Changed 3 years ago by nickm

Milestone: Tor: unspecified
Owner: nickm deleted

comment:23 Changed 3 years ago by nickm

Status: assignednew

comment:24 Changed 3 years ago by nickm

Parent ID: #17289

Unparenting.

comment:25 Changed 2 years ago by nickm

Keywords: 027-triaged-in added

comment:26 Changed 2 years ago by nickm

Keywords: 027-triaged-in removed

comment:27 Changed 2 years ago by nickm

Keywords: 027-triaged-1-in removed

comment:28 Changed 23 months ago by nickm

I've just run the numbers again -- this time as a count of lines per function rather than cyclomatic complexity. (Rationale: nearly all complexity metrics are highly correlated, so why not just use the easy one.) I'm attaching a list of every function with at least 100 lines. I've opened a child ticket to work on the worst offenders.

Changed 23 months ago by nickm

Attachment: longest-functions.txt added

functions with >= 100 lines

comment:29 Changed 23 months ago by nickm

Keywords: tor-relay, intro, tor-tests-coverage, tor-tests-unittor-relay, intro, tor-tests-coverage, tor-tests-unit intro
Points: 6
Note: See TracTickets for help on using tickets.