Method Naming Convention

ID

swift.naming_method

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

Swift

Tags

naming

Description

Reports function (method) names that do not follow Swift’s lowerCamelCase convention. The expected pattern is configurable.

Rationale

Swift’s API design guidelines specify that functions and methods use lowerCamelCase. Deviations confuse readers, break tool expectations (autocompletion, refactoring) and look inconsistent with the standard library.

// Bad
func DoThing() {}
func do_thing() {}

// Good
func doThing() {}
func handleRequest() {}

Exceptions

The rule deliberately does not flag:

  • operator overloads such as func +(a: A, b: A) → A;

  • names starting with an underscore (private-by-convention helpers);

  • methods following the XCTest naming style (test_xxx) inside an XCTestCase subclass.

Parameters

methodNamePattern

Regular expression a method name must match. Defaults to ^[a-z][a-zA-Z0-9]*$.

Remediation

Rename the method using lowerCamelCase. Remove underscores and ensure the first character is lowercase.