Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Conflict Search Error #224

Open
cjtafoya512 opened this issue Feb 6, 2025 · 0 comments
Open

Potential Conflict Search Error #224

cjtafoya512 opened this issue Feb 6, 2025 · 0 comments

Comments

@cjtafoya512
Copy link

cjtafoya512 commented Feb 6, 2025

There appears to be a logic issue with the following name conflict finding sub-routines. These methods exist in edifify_names.py
 

    def _conflicts_good(self, obj, identifier, objects):
        for element in objects:
            if element == obj:
                continue
            if element.name == identifier or (
                "EDIF.identifier" in element.data
                and element["EDIF.identifier"] == identifier
            ):
                return False
        return True
    def _conflicts_fix(self, obj, identifier, objects):
        identifier_lower = identifier.lower()
        if not self._conflicts_good(obj, identifier_lower, objects):
            pattern = re.compile("_sdn_[0-9]+_$")
            r = pattern.search(identifier_lower)
            if r is None:
                identifier_lower = identifier_lower + "_sdn_1_"
            else:
                # get the number out of the string
                num = int(re.search(r"\d+", identifier_lower[r.start() :]).group())
                identifier_lower = (
                    identifier_lower[: r.start() + 5] + str(num + 1) + "_"
                )
            identifier_lower = self._length_fix(identifier_lower)
            identifier_lower = self._conflicts_fix(obj, identifier_lower, objects)
            identifier = identifier_lower
        return identifier

The medhod _conflict_fix() is making a lowercase version of the "identifier" parameter named "identifier_lower". It then tests if "identifier_lower" has any conflicts. If it does not have any conflicts, it returns the original un-modified "identifier". I believe it is possible for "identifier" to have a conflict, even if "identifier_lower" does not have a conflict. Python does perform case sensitive string comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant