Skip to content

redundant-object ignores Φ-rooted references and flags attributes that are used #1276

Description

@yegor256

The redundant-object rule reports an attribute as redundant whenever the only
references to it are written in absolute form. In objectionary/eo, the file
eo-runtime/src/main/eo/os.eo declares is-linux at line 14 and reads it three
times, at lines 36, 41 and 42, always as os.is-linux. The lint still says:

os:14 The object "is-linux" is redundant and may be inlined (redundant-object/S)

The referenced-by-name key in
src/main/resources/org/eolang/lints/misc/redundant-object.xsl:11 indexes only
those o[@base] whose @base matches ^ξ(?:\.ρ)*\., so the three references
above, which the parser writes as Φ.os.is-linux and Φ.os.is-linux.and, are
counted as zero. The same blindness hits every public attribute of a library
object, since callers in other files can only reach it through Φ: on
eo-runtime the rule reports 166 defects and 74 of them are API attributes such
as win32.rdonly, tuple.empty, posix.stdout and number.as-i16, none of
which can be inlined.

Extend the key to index Φ-rooted references too: when @base matches
^Φ\., use the token that follows the name of the top object in
/object/o/@name, instead of mapping the whole reference to the empty string.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions