Skip to content

Sharing iP code quality feedback [for @wkxcass] - Round 2 #4

Description

@soc-se-bot-blue

@wkxcass We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).

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

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

Example from src/test/java/moimoi/util/command/AddCommandTest.java lines 31-101:

    public void execute_missingArguments_missingArgumentExceptionThrown() {

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.DEADLINE, "dummy");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.DEADLINE, "dummy /before 2024-08-22 18:00");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.EVENT,
                    "dummy /start 2024-08-22 18:00 /to 2024-08-22 18:30");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.EVENT,
                    "dummy /from 2024-08-22 40:00 /end 2024-08-22 18:30");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.DEADLINE, " /by 2024-08-22 18:00");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.PERIOD, "dummy /for ");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.EVENT,
                    "dummy /from  /to 2024-08-22 18:30");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.EVENT,
                    "dummy /from 2024-08-22 18:00 /to ");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new MissingArgumentException().getMessage(), e.getMessage());
        }

    }

Example from src/test/java/moimoi/util/command/AddCommandTest.java lines 104-148:

    public void execute_invalidDateTime_invalidDateTimeExceptionThrown() {

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.DEADLINE, "dummy /by 2024-08-22 40:00");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidDateTimeException("date-time").getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.DEADLINE, "dummy /by 2024-8-22 18:00");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidDateTimeException("date-time").getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.DEADLINE, "dummy /by 2024-8-22 1:00");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidDateTimeException("date-time").getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.EVENT,
                    "dummy /from 2024-08-22 18:00 /to 2024-08-40 18:30");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidDateTimeException("date-time").getMessage(), e.getMessage());
        }

        try {
            AddCommand addCommand = new AddCommand(CommandEnum.EVENT,
                    "dummy /from 2024-08-40 18:00 /to 2024-09-22 18:30");
            addCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidDateTimeException("date-time").getMessage(), e.getMessage());
        }

    }

Example from src/test/java/moimoi/util/command/DeleteTest.java lines 32-76:

    public void execute_invalidIndex_invalidIndexExceptionThrown() {

        try {
            DeleteCommand deleteCommand = new DeleteCommand("1");
            deleteCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidIndexException().getMessage(), e.getMessage());
        }

        this.tasks.add(this.task);

        try {
            DeleteCommand deleteCommand = new DeleteCommand("a");
            deleteCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidIndexException().getMessage(), e.getMessage());
        }

        try {
            DeleteCommand deleteCommand = new DeleteCommand("10");
            deleteCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidIndexException().getMessage(), e.getMessage());
        }

        try {
            DeleteCommand deleteCommand = new DeleteCommand("-1");
            deleteCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidIndexException().getMessage(), e.getMessage());
        }

        try {
            DeleteCommand deleteCommand = new DeleteCommand("0");
            deleteCommand.execute(this.storage, this.tasks);
            fail();
        } catch (MoiMoiException e) {
            assertEquals(new InvalidIndexException().getMessage(), 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

No easy-to-detect issues 👍

Aspect: Binary files in repo

No easy-to-detect issues 👍


❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality 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 cs2103@comp.nus.edu.sg if you want to follow up on this post.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions