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

XmlGraph issue #553

Closed
starkda opened this issue Apr 6, 2024 · 4 comments
Closed

XmlGraph issue #553

starkda opened this issue Apr 6, 2024 · 4 comments

Comments

@starkda
Copy link
Contributor

starkda commented Apr 6, 2024

XmlGraph (https://github.com/cqfn/jpeek/blob/master/src/main/java/org/jpeek/graph/XmlGraph.java) is used to represent methods and their relations for each class from input skeleton. But current implementation ignores constructors and static methods:
https://github.com/cqfn/jpeek/blob/9f4fc55048c2af466d5f81ca01a6f36f41537fa9/src/main/java/org/jpeek/graph/XmlGraph.java#L97C13-L99C14
Therefore, resulting graph may be incorrect for cases when we want to include constructors or static methods in metric calculation.
For example, we want to include constructor and input class is:

public final class Bar {
    private final Object key;
    private final Object value;
    private static String singleton = "";
    private static final String NAME = "hey";
    public Bar(final Object keyy, final Object val) {
        this.key = keyy;
        this.value = val;
        Bar.singleton = "hi";
    }
    public Object getKey() {
        Bar.singleton = "bye";
        Bar.NAME.length();
        return this.key;
    }
    public Object getValue() {
        Bar.NAME.length();
        return this.value;
    }
    public Object setValue(final Object val) {
        throw new UnsupportedOperationException("This object is immutable.");
    }
}

the code that finds nodes of graph:

final List<Node> nodes = new XmlGraph(
            new Skeleton(new FakeBase(XmlGraphTest.CLASS_NAME)),
            "", XmlGraphTest.CLASS_NAME
        ).nodes();

Size of nodes would be 3, while it should be 4.

@starkda
Copy link
Contributor Author

starkda commented Apr 6, 2024

@yegor256 what do you think?
Can I take that issue?

@yegor256
Copy link
Member

yegor256 commented Apr 7, 2024

@starkda this is done for a reason. I don't remember, what is the reason, but we should find out. It doesn't look like a bug to me, but as a feature. just removing it -- is not a solution.

@starkda
Copy link
Contributor Author

starkda commented Apr 7, 2024

@yegor256 i do not want to remove it but support parameters, more specifically, i want to add one more constructor with parameters

I am planning to use XmlGraph in #522 but without support of parameters it can be impossible

@starkda
Copy link
Contributor Author

starkda commented Apr 7, 2024

After some investigation, I found out that project already has xsl templates to get rid of constructors/static methods.
Closing issue

@starkda starkda closed this as completed Apr 7, 2024
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

2 participants