isEqual: overridden without hash

ID

objectivec.correctness.missing_hash

Severity

low

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Api Misuse

Language

Objective-C

Description

This class overrides isEqual: but not hash. Two objects that compare equal must return the same hash, so without it the class misbehaves in NSSet and as an NSDictionary key. Override hash over the same fields isEqual: compares.

Rationale

This class overrides isEqual: but not hash. Two objects that compare equal must return the same hash, so without it the class misbehaves in NSSet and as an NSDictionary key. Override hash over the same fields isEqual: compares.

The following code illustrates the pattern detected by this rule:

// FLAGGED: isEqual: overridden without hash
@implementation NoHash
- (BOOL)isEqual:(id)other {
    return YES;
}
@end

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved