Code Monkey home page Code Monkey logo

ip's People

Contributors

damithc avatar j-lum avatar jiachen247 avatar thesoggy avatar

ip's Issues

Sharing iP code quality feedback [for @TheSoggy]

@TheSoggy 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/duke/Duke.java lines 18-18:

    private boolean tasksEnd = 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/Parser.java lines 51-150:

    public static Command parseCommand(String input) throws DukeException {
        String[] inputs = input.split(" ", 2);
        CommandType commandType = CommandType.fromString(inputs[0].toUpperCase());

        if (commandType == null) {
            throw new DukeException("Invalid command: Please try again.");
        }

        String description;

        switch (commandType) {
        case BYE:
            return new ByeCommand();
        case LIST:
            return new ListCommand();
        case EMPTY:
            return new EmptyCommand();
        case MARK:
            if (inputs.length == 1) {
                throw new DukeException("Wrong number of arguments.");
            }
            try {
                int index = Integer.parseInt(inputs[1]) - 1;
                return new SetDoneCommand(index, true);
            } catch (NumberFormatException e) {
                throw new DukeException("Invalid argument: Index of task should be a number.");
            } catch (IndexOutOfBoundsException e) {
                throw new DukeException("Invalid argument: Index of task should be between 1 and the number of tasks.");
            }
        case UNMARK:
            if (inputs.length == 1) {
                throw new DukeException("Wrong number of arguments.");
            }
            try {
                int index = Integer.parseInt(inputs[1]) - 1;
                return new SetDoneCommand(index, false);
            } catch (NumberFormatException e) {
                throw new DukeException("Invalid argument: Index of task should be a number.");
            } catch (IndexOutOfBoundsException e) {
                throw new DukeException("Invalid argument: Index of task should be between 1 and the number of tasks.");
            }
        case TODO:
            if (inputs.length == 1) {
                throw new DukeException("Wrong number of arguments.");
            }
            description = inputs[1];
            if (description.length() == 0) {
                throw new DukeException("Invalid argument: Description cannot be empty.");
            }
            return new AddTaskCommand(new TodoTask(description, false));
        case DEADLINE:
            if (inputs.length == 1) {
                throw new DukeException("Wrong number of arguments.");
            }
            try {
                description = inputs[1].substring(0, inputs[1].indexOf(" /by "));
                if (description.length() == 0) {
                    throw new DukeException("Invalid argument: Description cannot be empty.");
                }
                String deadline = inputs[1].substring(inputs[1].indexOf(" /by ") + 5);
                if (deadline.length() == 0) {
                    throw new DukeException("Invalid argument: Deadline cannot be empty.");
                }
                return new AddTaskCommand(new DeadlineTask(description, Parser.parseDateTime(deadline), false));
            } catch (StringIndexOutOfBoundsException e) {
                throw new DukeException("Invalid argument: Use /by flag to specify the deadline of the task");
            }
        case EVENT:
            if (inputs.length == 1) {
                throw new DukeException("Wrong number of arguments.");
            }
            try {
                description = inputs[1].substring(0, inputs[1].indexOf(" /at "));
                if (description.length() == 0) {
                    throw new DukeException("Invalid argument: Description cannot be empty.");
                }
                String time = inputs[1].substring(inputs[1].indexOf(" /at ") + 5);
                if (time.length() == 0) {
                    throw new DukeException("Invalid argument: Event time cannot be empty.");
                }
                return new AddTaskCommand(new EventTask(description, Parser.parseDateTime(time), false));
            } catch (StringIndexOutOfBoundsException e) {
                throw new DukeException("Invalid argument: Use /at flag to specify the date and time of the event.");
            }
        case DELETE:
            if (inputs.length == 1) {
                throw new DukeException("Wrong number of arguments.");
            }
            try {
                int index = Integer.parseInt(inputs[1]) - 1;
                return new DeleteTaskCommand(index);
            } catch (NumberFormatException e) {
                throw new DukeException("Invalid argument: Index of task should be a number.");
            } catch (IndexOutOfBoundsException e) {
                throw new DukeException("Invalid argument: Index of task should be between 1 and the number of tasks.");
            }
        default:
            throw new DukeException("Invalid command: Please try again.");
        }
    }

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 (Subject Only)

No easy-to-detect issues ๐Ÿ‘

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.

Sharing iP code quality feedback [for @TheSoggy] - Round 2

@TheSoggy We did an automated analysis of your code to detect potential areas to improve the code quality. The script did not detect any issues in your code (nice!).

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

Aspect: Tab Usage

No easy-to-detect issues ๐Ÿ‘

Aspect: Naming boolean variables/methods

No easy-to-detect issues ๐Ÿ‘

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

No easy-to-detect issues ๐Ÿ‘

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

No easy-to-detect issues ๐Ÿ‘

Aspect: Recent Git Commit Message (Subject Only)

No easy-to-detect issues ๐Ÿ‘

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.