Skip to content

check code quality of java file#4

Open
fathimanabeela wants to merge 3 commits intoUpcode-Software-Labs:mainfrom
fathimanabeela:code-check/file
Open

check code quality of java file#4
fathimanabeela wants to merge 3 commits intoUpcode-Software-Labs:mainfrom
fathimanabeela:code-check/file

Conversation

@fathimanabeela
Copy link

have checked the code quality of a java file read from github using checkstyle and updated the result in db

HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

if (response.statusCode() == 200) {
Copy link
Contributor

Choose a reason for hiding this comment

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

use HTTPS status code constant instead of 200

}

public static String codeCheck(String javaCode) throws CheckstyleException, IOException {
String result;
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to declare the variable here

} else {
result = auditListener.getViolationsAsString();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

you can use a conditional operator here

String result;

// Create a Checkstyle Checker
Checker checker = new Checker();
Copy link
Contributor

Choose a reason for hiding this comment

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

always try to use final variables. So that the immutability is preserved

}

private static File createTempFile(String content) throws IOException {
File tempFile = File.createTempFile("tempJavaFile", ".java");
Copy link
Contributor

Choose a reason for hiding this comment

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

use final variable


@Test
void example() {
System.out.println("test");
Copy link
Contributor

Choose a reason for hiding this comment

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

add tests

@sujithps
Copy link
Contributor

@fathimanabeela please resolve conflicts

@fathimanabeela
Copy link
Author

fathimanabeela commented Apr 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants