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

Enable checkstyle && fix issues in entity/agent #375

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public String runPYFunction(SmartTestParam smartTestParam, Logger logger) throws
String[] runArgs = new String[7];
runArgs[0] = "python";
runArgs[1] = filePath;
runArgs[2] = smartTestParam.apkPath;
runArgs[3] = smartTestParam.deviceInfo;
runArgs[4] = smartTestParam.modelInfo;
runArgs[5] = smartTestParam.testSteps;
runArgs[6] = smartTestParam.stringTextFolder;
runArgs[2] = smartTestParam.getApkPath();
runArgs[3] = smartTestParam.getDeviceInfo();
runArgs[4] = smartTestParam.getModelInfo();
runArgs[5] = smartTestParam.getTestSteps();
runArgs[6] = smartTestParam.getStringTextFolder();

for (String tempArg : runArgs) {
logger.info(tempArg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void captureDevicesScreenSync(Collection<DeviceInfo> allDevices, boolean
return;
}

CountDownLatch countDownLatch = deviceTaskControl.countDownLatch;
CountDownLatch countDownLatch = deviceTaskControl.getCountDownLatch();
try {
countDownLatch.await();
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public boolean doTask(DeviceInfo deviceInfo, Logger logger) throws Exception {
if (deviceTaskControl == null) {
testTask.setTestDevicesCount(0);
} else {
testTask.setTestDevicesCount(deviceTaskControl.devices.size());
testTask.setTestDevicesCount(deviceTaskControl.getDevices().size());
}
return testTask;
}
Expand Down
4 changes: 4 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = '0.9.5'
sourceCompatibility = 11
targetCompatibility = 11

apply from: "${project.rootDir}/quality/checkstyle.gradle"

def env = System.getProperty("env") ?: "dev"

sourceSets {
Expand All @@ -14,6 +16,8 @@ sourceSets {
}
}

classes.finalizedBy checkstyleMain

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package com.microsoft.hydralab.common.entity.agent;

package com.microsoft.hydralab.common.entity.agent;

import com.microsoft.hydralab.common.management.listener.MobileDeviceState;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package com.microsoft.hydralab.common.entity.agent;

import com.microsoft.hydralab.common.entity.common.DeviceInfo;
Expand All @@ -8,11 +9,19 @@
import java.util.concurrent.CountDownLatch;

public class DeviceTaskControl {
public final CountDownLatch countDownLatch;
public final Set<DeviceInfo> devices;
private final CountDownLatch countDownLatch;
private final Set<DeviceInfo> devices;

public DeviceTaskControl(CountDownLatch countDownLatch, Set<DeviceInfo> devices) {
this.countDownLatch = countDownLatch;
this.devices = devices;
}

public CountDownLatch getCountDownLatch() {
return countDownLatch;
}

public Set<DeviceInfo> getDevices() {
return devices;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package com.microsoft.hydralab.common.entity.agent;

import lombok.Data;
Expand Down Expand Up @@ -33,8 +34,12 @@ public MobileDevice() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we consider allowing this style and disabling this rule entirely? I this the oneliner is quite useful and readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove NeedBraces in our checkstyle-ruleset.xml, but I personally don't like non-braces style xD

if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MobileDevice that = (MobileDevice) o;
return Objects.equals(serialNum, that.serialNum);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package com.microsoft.hydralab.common.entity.agent;

import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package com.microsoft.hydralab.common.entity.agent;

import com.alibaba.fastjson.JSONObject;
import com.microsoft.hydralab.common.util.Const;
import com.microsoft.hydralab.common.entity.common.DeviceInfo;
import com.microsoft.hydralab.common.util.Const;
import lombok.Data;

@Data
public class SmartTestParam {
public String apkPath;
public String deviceInfo;
public String modelInfo;
public String testSteps;
public String stringTextFolder;
private String apkPath;
private String deviceInfo;
private String modelInfo;
private String testSteps;
private String stringTextFolder;

public SmartTestParam(String apkPath, DeviceInfo deviceInfo, String sourceModelId, String targetModelId, int testSteps, String folderPath, String stringFolderPath) {
JSONObject modelInfo = new JSONObject();
Expand Down
11 changes: 11 additions & 0 deletions quality/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@
<suppressions>
<suppress checks="[a-zA-Z0-9]*" files="R.java"/>
<suppress checks="[a-zA-Z0-9]*" files="BuildConfig.java"/>
<!-- suppress temperately -->
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]util[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]file[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]entity[\\/]center[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]entity[\\/]common[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]logger[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]management[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]monitor[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]repository[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]common[\\/]screen[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="hydralab[\\/]performance[\\/]" />
</suppressions>