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

Use Palantir format instead of Google Java Format #262

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,8 @@
<!-- define a language-specific format -->
<java>
<!-- no need to specify files, inferred automatically -->
<!-- apply a specific flavor of google-java-format -->
<googleJavaFormat>
<version>1.15.0</version>
<style>AOSP</style>
</googleJavaFormat>
<endWithNewline />
<palantirJavaFormat />
<removeUnusedImports />
</java>
<pom>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class ElasticAxis extends LabelAxis {
private final boolean dontExpandLabels;

@DataBoundConstructor
public ElasticAxis(
String name, String labelString, boolean ignoreOffline, boolean dontExpandLabels) {
public ElasticAxis(String name, String labelString, boolean ignoreOffline, boolean dontExpandLabels) {
super(name, computeAllNodesInLabel(labelString, dontExpandLabels));
this.label = labelString;
this.ignoreOffline = ignoreOffline;
Expand Down Expand Up @@ -86,8 +85,7 @@ private static List<String> computeNodesInLabel(
hudson.model.Label agentLabel = Jenkins.get().getLabel(aLabel.trim());
if (agentLabel != null) {
for (Node node : agentLabel.getNodes()) {
if (shouldAddNode(restrictToOnlineNodes, node.toComputer()))
onlineNodesForLabel = true;
if (shouldAddNode(restrictToOnlineNodes, node.toComputer())) onlineNodesForLabel = true;
}
if (onlineNodesForLabel) {
computedNodes.add(agentLabel.getExpression());
Expand Down Expand Up @@ -125,28 +123,24 @@ public Axis newInstance(StaplerRequest req, JSONObject formData) throws FormExce
}

@RequirePOST
public FormValidation doCheckLabelString(
@AncestorInPath Job<?, ?> job, @QueryParameter String value) {
public FormValidation doCheckLabelString(@AncestorInPath Job<?, ?> job, @QueryParameter String value) {
job.checkPermission(hudson.model.Item.CONFIGURE);
String[] labels = value.split(",");
List<FormValidation> aggregatedNotOkValidations = new ArrayList<>();
for (String oneLabel : labels) {
FormValidation validation = LabelExpression.validate(oneLabel, job);
if (!validation.equals(FormValidation.ok())) {
LOGGER.log(
Level.FINEST,
"Remembering not ok validation {1} for label {0}",
new Object[] {oneLabel, validation});
LOGGER.log(Level.FINEST, "Remembering not ok validation {1} for label {0}", new Object[] {
oneLabel, validation
});
aggregatedNotOkValidations.add(validation);
}
}
if (!aggregatedNotOkValidations.isEmpty()) {
FormValidation aggregatedValidations =
FormValidation.aggregate(aggregatedNotOkValidations);
LOGGER.log(
Level.FINEST,
"Returning aggregated not ok validation {1} for labels {0}",
new Object[] {labels, aggregatedValidations});
FormValidation aggregatedValidations = FormValidation.aggregate(aggregatedNotOkValidations);
LOGGER.log(Level.FINEST, "Returning aggregated not ok validation {1} for labels {0}", new Object[] {
labels, aggregatedValidations
});
return aggregatedValidations;
}
LOGGER.log(Level.FINEST, "Returning ok validation for labels {0}", labels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
@RunWith(Parameterized.class)
public class ElasticAxisTest {

@ClassRule public static JenkinsRule j = new JenkinsRule();
@ClassRule
public static JenkinsRule j = new JenkinsRule();

private final String axisName;
private final String labelString;
Expand Down Expand Up @@ -79,15 +80,11 @@ public static Collection permuteTestArguments() {
for (Boolean doNotExpandLabels : possibleValues) {
for (String labelSuffix : LABEL_SUFFIXES) {
// Test for known agents
Object[] argument = {
AGENT_PREFIX + labelSuffix, ignoreOffline, doNotExpandLabels
};
Object[] argument = {AGENT_PREFIX + labelSuffix, ignoreOffline, doNotExpandLabels};
arguments.add(argument);
}
// Test that a non-existing agent matches nothing
Object[] argument = {
AGENT_PREFIX + DOES_NOT_EXIST_SUFFIX, ignoreOffline, doNotExpandLabels
};
Object[] argument = {AGENT_PREFIX + DOES_NOT_EXIST_SUFFIX, ignoreOffline, doNotExpandLabels};
arguments.add(argument);
}
}
Expand Down Expand Up @@ -141,9 +138,7 @@ public void testGetValues() {
public void testGetValuesForController() {
// selfLabel will be "master" before 2.307 and "built-in" after 2.307
String expectedLabel = j.jenkins.getSelfLabel().getName();
elasticAxis =
new ElasticAxis(
axisName, expectedLabel + " || built-in", ignoreOffline, doNotExpandLabels);
elasticAxis = new ElasticAxis(axisName, expectedLabel + " || built-in", ignoreOffline, doNotExpandLabels);
if (doNotExpandLabels) {
assertThat(elasticAxis.getValues(), hasItem(expectedLabel + "||built-in"));
} else {
Expand All @@ -153,8 +148,7 @@ public void testGetValuesForController() {

@Test
public void testGetValuesForAgentAOrAgentB() {
elasticAxis =
new ElasticAxis(axisName, "label-A || label-B", ignoreOffline, doNotExpandLabels);
elasticAxis = new ElasticAxis(axisName, "label-A || label-B", ignoreOffline, doNotExpandLabels);
if (doNotExpandLabels) {
assertThat(elasticAxis.getValues(), hasItem("label-A||label-B"));
} else {
Expand Down