Skip to content

Commit

Permalink
refactor: remove GitLabProject name field
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Howard <[email protected]>
  • Loading branch information
jhoward-lm committed Feb 24, 2025
1 parent 1a0f052 commit cc785c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,14 @@ GitLabRole getStringValue() {
}
}

private final String name;
private final String fullPath;

Check notice on line 44 in src/main/java/org/dependencytrack/integrations/gitlab/GitlabProject.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/main/java/org/dependencytrack/integrations/gitlab/GitlabProject.java#L44

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
private final MaxAccessLevel maxAccessLevel;

Check notice on line 45 in src/main/java/org/dependencytrack/integrations/gitlab/GitlabProject.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/main/java/org/dependencytrack/integrations/gitlab/GitlabProject.java#L45

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.

GitLabProject(final String name, final String fullPath, final GitLabRole maxAccessLevel) {
this.name = name;
GitLabProject(final String fullPath, final GitLabRole maxAccessLevel) {
this.fullPath = fullPath;
this.maxAccessLevel = new MaxAccessLevel(maxAccessLevel);
}

public String getName() {
return name;
}

public String getFullPath() {
return fullPath;
}
Expand All @@ -65,20 +59,18 @@ public MaxAccessLevel getMaxAccessLevel() {

public static GitLabProject parse(final String data) {
JSONObject obj = JSONValue.parse(data, JSONObject.class);
String name = obj.getAsString("name");
String fullPath = obj.getAsString("fullPath");

JSONObject maxAccessLevel = (JSONObject) obj.get("maxAccessLevel");
String stringValue = maxAccessLevel.getAsString("stringValue");

return new GitLabProject(name, fullPath, GitLabRole.valueOf(stringValue));
return new GitLabProject(fullPath, GitLabRole.valueOf(stringValue));
}

@Override
public String toString() {
return "%s{name=%s, fullPath=%s, maxAccessLevel=%s}".formatted(
return "%s{fullPath=%s, maxAccessLevel=%s}".formatted(
getClass().getSimpleName(),
name,
fullPath,
maxAccessLevel.getStringValue().toString());
}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/graphql/gitlab-projects.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ query (
after: $cursor
) {
nodes {
name
fullPath
maxAccessLevel {
stringValue
Expand Down

0 comments on commit cc785c8

Please sign in to comment.