Skip to content

fix: ApiDeleteGroupPolicies #613

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

Merged
merged 2 commits into from
Jan 20, 2025
Merged

Conversation

YangSen-qn
Copy link
Collaborator

No description provided.

@qiniu-prow qiniu-prow bot added the size/L label Jan 17, 2025
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class GroupPolicyApiTest {
Copy link

Choose a reason for hiding this comment

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

【GroupPolicyApiTest】缺少包含@author的注释信息

Details

lint 解释

在Java代码中,@author 注释用于标识代码的作者。根据代码规范和最佳实践,每个类、接口或方法都应该包含 @author 注释,以便其他开发者了解代码的来源。

错误用法

public class GroupPolicyApiTest {
    // 缺少 @author 注释
}

正确用法

/**
 * @author 你的名字或团队名称
 */
public class GroupPolicyApiTest {
    // 类的内容
}

💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流


@Test
@Tag("IntegrationTest")
public void testGroupPolicyApi() {
Copy link

Choose a reason for hiding this comment

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

方法【testGroupPolicyApi】的总行数不要超过80行。

Details

lint 解释

该lint结果提示在方法 testGroupPolicyApi 中,代码的总行数超过了推荐的80行。这可能会导致代码难以阅读和维护。

错误用法

以下是一个示例,展示了可能违反此规则的代码:

public void testGroupPolicyApi() {
    // 假设这里有很多行代码
    for (int i = 0; i < 100; i++) {
        System.out.println("Line " + i);
    }
    // 更多代码...
}

正确用法

为了遵守此规则,可以将代码拆分为多个方法或提取公共逻辑到单独的方法中。以下是一个改进的示例:

public void testGroupPolicyApi() {
    setupTestEnvironment();
    performAssertions();
    cleanUpResources();
}

private void setupTestEnvironment() {
    // 设置测试环境的代码
    for (int i = 0; i < 50; i++) {
        System.out.println("Setup Line " + i);
    }
}

private void performAssertions() {
    // 执行断言的代码
    for (int i = 50; i < 100; i++) {
        System.out.println("Assertion Line " + i);
    }
}

private void cleanUpResources() {
    // 清理资源的代码
}

通过这种方式,可以将 testGroupPolicyApi 方法拆分为多个更小的方法,每个方法只负责一个功能,从而提高代码的可读性和可维护性。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

@YangSen-qn
Copy link
Collaborator Author

qiniu-java-sdk11-presubmit-integration-test

@@ -77,7 +77,10 @@ public void testQuery() {


} catch (QiniuException e) {
throw new RuntimeException(e);
if (e.response == null || e.response.statusCode != 400) {
Copy link

Choose a reason for hiding this comment

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

魔法值【400】

Details

lint 解释

在代码中使用了硬编码的数字(magic number),即直接在代码中使用了没有解释的数值。这种做法可能会导致代码难以理解和维护,因为如果需要更改这个数值,可能需要在整个代码库中查找并替换。

错误用法

if (responseCode == 400) {
    // 处理错误情况
}

在这个例子中,400 是一个硬编码的数字,表示HTTP状态码“Bad Request”。

正确用法

为了避免使用魔法值,可以定义一个常量来代替这个数值。这样,如果需要更改这个数值,只需要在一个地方进行修改。

public static final int HTTP_BAD_REQUEST = 400;

if (responseCode == HTTP_BAD_REQUEST) {
    // 处理错误情况
}

通过这种方式,代码的可读性和维护性都得到了提升。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

@YangSen-qn
Copy link
Collaborator Author

/test qiniu-java-sdk11-presubmit-integration-test

@YangSen-qn
Copy link
Collaborator Author

/test qiniu-java-sdk8-presubmit-integration-test

@YangSen-qn YangSen-qn merged commit 63ac56c into qiniu:master Jan 20, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants