Let’s say we have an Angular component:
@Component({
selector: 'app-location-search',
styleUrls: ['./location-search.component.scss'],
templateUrl: './location-search.component.html'
})
export class LocationSearchComponent {
@Input()
set location(location: LocationAddress) {
if (location && location.code) {
this.searchTerm = location.city;
}
}
//...
This will trigger typescript:S2376 in SonarCloud, with rationale:
When an object is created with a setter for a property but without a getter for that property, the property is inaccessible and is thus useless.
However, given usage of Angular components is more along the lines of:
<div class="input-group">
<app-location-search [index]="i" [showLabel]="false"
[location]="deliveryLocations[0]"
(locationSelected)="setSelectedLocation($event)"
</app-location-search>
</div>
So you wouldn’t ever “get” the value, you’d react to the event that tells you there is a new value, which makes the rule seem like a false positive.