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

Sharing iP code quality feedback [for @HusseinSafwan02] #1

Open
soc-se-bot-red opened this issue Feb 17, 2024 · 0 comments
Open

Sharing iP code quality feedback [for @HusseinSafwan02] #1

soc-se-bot-red opened this issue Feb 17, 2024 · 0 comments

Comments

@soc-se-bot-red
Copy link

@HusseinSafwan02 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.

IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.

Aspect: Tab Usage

No easy-to-detect issues 👍

Aspect: Naming boolean variables/methods

Example from src/main/java/Task.java lines 3-3:

    private Boolean status = false;

Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)

Aspect: Brace Style

No easy-to-detect issues 👍

Aspect: Package Name Style

No easy-to-detect issues 👍

Aspect: Class Name Style

No easy-to-detect issues 👍

Aspect: Dead Code

No easy-to-detect issues 👍

Aspect: Method Length

Example from src/main/java/Duke.java lines 88-167:

    public static void main(String[] args) {
        System.out.println(introMessage());
        Scanner sc = new Scanner(System.in);
        String userInput;
        FileManager fileManager = new FileManager("./data/duke.txt");
        ArrayList<Task> tasks = fileManager.loadTasks();
        int count = 0;

        try {
            while(true) {
                userInput = sc.nextLine();
                String[] userInputArray = userInput.split("\\s+", 2);

                boolean isTodo = userInputArray[0].equals("todo");
                boolean isDeadline = userInputArray[0].equals("deadline");
                boolean isEvent = userInputArray[0].equals("event");
                boolean isMark = userInputArray[0].equals("mark");
                boolean isUnmark = userInputArray[0].equals("unmark");
                char lastChar = userInput.charAt(userInput.length() - 1);


                if (userInput.equals("bye")) {
                    System.out.println(outroMessage());
                    break;
                } else if (userInputArray[0].equals("list")) {
                    listTasks(tasks, count);
                } else if (isTodo || isEvent || isDeadline) {
                    if (isTodo) {
                        tasks.add(new Todo(userInputArray[1], false));
                        count++;
                        System.out.println(addComment(tasks.get(count - 1), count));
                        fileManager.saveTasks(tasks);
                    }
                    if (isEvent) {
                        String task = getTask(userInput);
                        int index = userInput.indexOf("/");
                        String when = replacer(userInput).substring(index);
                        tasks.add(new Event(task, false, when));
                        count++;
                        System.out.println(addComment(tasks.get(count - 1), count));
                        fileManager.saveTasks(tasks);
                    }
                    if (isDeadline) {
                        int index = userInput.indexOf("/by") + 4;
                        String dateString = userInput.substring(index, userInput.length());
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm");
                        LocalDateTime dateTime = LocalDateTime.parse(dateString, formatter);
                        String task = getTask(userInput);
                        tasks.add(new Deadline(task, false, dateTime));
                        count++;
                        System.out.println(addComment(tasks.get(count - 1), count));
                        fileManager.saveTasks(tasks);
                    }

                } else if (isMark || isUnmark) {
                    if (isMark) {
                        int lastNumber = Character.getNumericValue(lastChar);
                        tasks.get(lastNumber - 1).finishTask();
                        System.out.println(markMessage(tasks.get(lastNumber - 1)));
                        fileManager.saveTasks(tasks);
                    } else {
                        int lastNumber = Character.getNumericValue(lastChar);
                        tasks.get(lastNumber - 1).redoTask();
                        System.out.println(markMessage(tasks.get(lastNumber - 1)));
                        fileManager.saveTasks(tasks);
                    }
                } else if (userInputArray[0].equals("delete")) {
                    int index = Character.getNumericValue(lastChar);
                    Task temp = tasks.get(index - 1);
                    tasks.remove(index - 1);
                    System.out.println(deleteMessage(temp, tasks.size()));
                    fileManager.saveTasks(tasks);
                } else {
                    throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
                }
            }
        } catch (DukeException e) {
            System.out.println(e.getMessage());
        }
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.

Aspect: Class size

No easy-to-detect issues 👍

Aspect: Header Comments

No easy-to-detect issues 👍

Aspect: Recent Git Commit Message

possible problems in commit 1c6ae92:


Saving feature


  • Not in imperative mood (?)

possible problems in commit daa138e:


Automated Text-UI-Testing


  • Not in imperative mood (?)

Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).

Aspect: Binary files in repo

No easy-to-detect issues 👍


ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected] if you want to follow up on this post.

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

No branches or pull requests

1 participant