Skip to content

Commit

Permalink
Enable Spotless (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Aug 15, 2024
1 parent 936ac56 commit ef972a1
Show file tree
Hide file tree
Showing 82 changed files with 3,166 additions and 2,304 deletions.
457 changes: 227 additions & 230 deletions pom.xml

Large diffs are not rendered by default.

258 changes: 155 additions & 103 deletions src/main/java/hudson/tasks/junit/CaseResult.java

Large diffs are not rendered by default.

91 changes: 48 additions & 43 deletions src/main/java/hudson/tasks/junit/ClassResult.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer, id:cactusman, Tom Huybrechts, Yahoo!, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -45,10 +45,10 @@ public final class ClassResult extends TabulatedResult implements Comparable<Cla

private final Set<CaseResult> cases = new TreeSet<CaseResult>();

private int passCount,failCount,skipCount;
private float duration;
private int passCount, failCount, skipCount;

private float duration;

private long startTime;

private final PackageResult parent;
Expand All @@ -61,7 +61,7 @@ public ClassResult(PackageResult parent, String className) {

@Override
public Run<?, ?> getRun() {
return parent==null ? null: parent.getRun();
return parent == null ? null : parent.getRun();
}

@Override
Expand All @@ -71,12 +71,16 @@ public PackageResult getParent() {

@Override
public ClassResult getPreviousResult() {
if(parent==null) return null;
if (parent == null) {
return null;
}
TestResult pr = parent.getPreviousResult();
if(pr==null) return null;
if(pr instanceof PackageResult) {
return ((PackageResult)pr).getClassResult(getName());
}
if (pr == null) {
return null;
}
if (pr instanceof PackageResult) {
return ((PackageResult) pr).getClassResult(getName());
}
return null;
}

Expand All @@ -87,8 +91,8 @@ public hudson.tasks.test.TestResult findCorrespondingResult(String id) {
int base = id.indexOf(myID);
if (base > 0) {
int caseNameStart = base + myID.length() + 1;
if (id.length() > caseNameStart) {
caseName = id.substring(caseNameStart);
if (id.length() > caseNameStart) {
caseName = id.substring(caseNameStart);
}
}
return getCaseResult(caseName);
Expand All @@ -109,12 +113,15 @@ public String getChildType() {
return "case";
}

@Exported(visibility=999)
@Exported(visibility = 999)
@Override
public String getName() {
int idx = className.lastIndexOf('.');
if(idx<0) return className;
else return className.substring(idx+1);
if (idx < 0) {
return className;
} else {
return className.substring(idx + 1);
}
}

public @Override synchronized String getSafeName() {
Expand All @@ -123,27 +130,27 @@ public String getName() {
}
return safeName = uniquifyName(parent.getChildren(), safe(getName()));
}

public CaseResult getCaseResult(String name) {
for (CaseResult c : cases) {
if(c.getSafeName().equals(name))
if (c.getSafeName().equals(name)) {
return c;
}
}
return null;
}

@Override
public Object getDynamic(String name, StaplerRequest req, StaplerResponse rsp) {
CaseResult c = getCaseResult(name);
if (c != null) {
if (c != null) {
return c;
} else {
} else {
return super.getDynamic(name, req, rsp);
}
}
}


@Exported(name="child")
@Exported(name = "child")
@Override
public Collection<CaseResult> getChildren() {
return cases;
Expand All @@ -157,13 +164,13 @@ public boolean hasChildren() {
// TODO: wait for stapler 1.60 @Exported
@Override
public float getDuration() {
return duration;
return duration;
}

public long getStartTime() {
return startTime;
}

@Exported
@Override
public int getPassCount() {
Expand Down Expand Up @@ -196,17 +203,15 @@ public void add(CaseResult r) {
*/
@Override
public void tally() {
passCount=failCount=skipCount=0;
passCount = failCount = skipCount = 0;
duration = 0;
for (CaseResult r : cases) {
r.setClass(this);
if (r.isSkipped()) {
skipCount++;
}
else if(r.isPassed()) {
} else if (r.isPassed()) {
passCount++;
}
else {
} else {
failCount++;
}
duration += r.getDuration();
Expand All @@ -218,7 +223,7 @@ void freeze() {
}

public String getClassName() {
return className;
return className;
}

@Override
Expand Down Expand Up @@ -252,33 +257,33 @@ public int hashCode() {
public String getDisplayName() {
return TestNameTransformer.getTransformedName(getName());
}

/**
* @since 1.515
*/
@Override
public String getFullName() {
return getParent().getName() + "." + className;
return getParent().getName() + "." + className;
}

@Override
public String getFullDisplayName() {
return getParent().getDisplayName() + "." + TestNameTransformer.getTransformedName(className);
return getParent().getDisplayName() + "." + TestNameTransformer.getTransformedName(className);
}

/**
* Gets the relative path to this test case from the given object.
*/
@Override
public String getRelativePathFrom(TestObject it) {
if(it instanceof CaseResult) {
return "..";
if (it instanceof CaseResult) {
return "..";
} else {
return super.getRelativePathFrom(it);
}
}
public void setStartTime(long start) {

public void setStartTime(long start) {
this.startTime = start;
}

Expand Down
Loading

0 comments on commit ef972a1

Please sign in to comment.