Giter VIP home page Giter VIP logo

ip's Introduction

Duke project template

This is a project template for a greenfield Java project. It's named after the Java mascot Duke. Given below are instructions on how to use it.

Setting up in Intellij

Prerequisites: JDK 11, update Intellij to the most recent version.

  1. Open Intellij (if you are not in the welcome screen, click File > Close Project to close the existing project first)
  2. Open the project into Intellij as follows:
    1. Click Open.
    2. Select the project directory, and click OK.
    3. If there are any further prompts, accept the defaults.
  3. Configure the project to use JDK 11 (not other versions) as explained in here.
    In the same dialog, set the Project language level field to the SDK default option.
  4. After that, locate the src/main/java/roebot.Duke.java file, right-click it, and choose Run roebot.Duke.main() (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
    Hello from
     ____        _        
    |  _ \ _   _| | _____ 
    | | | | | | | |/ / _ \
    | |_| | |_| |   <  __/
    |____/ \__,_|_|\_\___|
    

ip's People

Contributors

cyqjoseph avatar j-lum avatar damithc avatar seanleong339 avatar jiachen247 avatar eclipse-dominator avatar

Stargazers

 avatar

ip's Issues

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

@cyqjoseph 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

Example from src/main/java/services/TaskList.java lines 172-173:

            }
            else {

Suggestion: As specified by the coding standard, use egyptian style braces.

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

possible problems in commit ed3364f:


Fix ArrayIndexOutOfBoundsException in parseTaskFromString

This commit addresses an issue where `parseTaskFromString` could throw an ArrayIndexOutOfBoundsException if the input string was not properly formatted. Replaced assert statements with explicit exception handling to ensure robust error checking, even when assertions are disabled at runtime.

Additionally, updated build.gradle to include platform-specific JavaFX dependencies for Windows, macOS, and Linux to support cross-platform functionality.

Dependencies added for javafx-base, javafx-controls, javafx-fxml, and javafx-graphics for each respective platform using the javaFxVersion variable for consistent version management.


  • body not wrapped at 72 characters: e.g., This commit addresses an issue where parseTaskFromString could throw an ArrayIndexOutOfBoundsException if the input string was not properly formatted. Replaced assert statements with explicit exception handling to ensure robust error checking, even when assertions are disabled at runtime.

possible problems in commit e88de4d:


Change file path in build.gradle.

Previously mainClass was set to Main, which was incorrect, fix to
Launcher class required to allow build jar file to run properly.

Update new jar file on github release tab.


  • Subject line should not end with a period

possible problems in commit 7117a48:


Add JavaDoc comments for markAsDone and markAsUndone.

This commit introduces two JavaDoc comments in the class Task

1. markAsDone(): Marks task as Done
2. markAsUndone(): Marks task as Undone.


  • Subject line should not end with a period

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 ๐Ÿ‘


โ— 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 [email protected] if you want to follow up on this post.

Sharing iP code quality feedback [for @cyqjoseph]

@cyqjoseph 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

No easy-to-detect issues ๐Ÿ‘

Aspect: Brace Style

Example from src/main/java/services/TaskList.java lines 175-176:

            // For other tasks, compare by name only
            else {

Suggestion: As specified by the coding standard, use egyptian style braces.

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/services/parser/Parser.java lines 204-251:

    public LocalDateTime parseDate(String dateString) throws DukeException {
        assert dateString != null && !dateString.isEmpty() : "dateString cannot be null or empty";
        List<DateTimeFormatter> dateTimeFormatters = Arrays.asList(
                DateTimeFormatter.ofPattern("d/M/yyyy HHmm"),
                DateTimeFormatter.ofPattern("d-M-yyyy HHmm"),
                DateTimeFormatter.ofPattern("yyyy-M-d HHmm"),
                DateTimeFormatter.ofPattern("d/M/yyyy HH:mm"),
                DateTimeFormatter.ofPattern("M/d/yyyy h:mm a"),
                DateTimeFormatter.ofPattern("yyyy-M-d HHmm"),
                DateTimeFormatter.ofPattern("d MMM yyyy h:mma"),
                DateTimeFormatter.ofPattern("MMM d, yyyy HH:mm"),
                DateTimeFormatter.ofPattern("yyyyMMdd h:mm a"),
                DateTimeFormatter.ofPattern("d-M-yyyy HH:mm"),
                DateTimeFormatter.ofPattern("yyyy/M/d h:mma"),
                DateTimeFormatter.ofPattern("d MMMM yyyy HHmm"),
                DateTimeFormatter.ofPattern("yyyy-M-d h:mm a")
        );

        List<DateTimeFormatter> dateFormatters = Arrays.asList(
                DateTimeFormatter.ofPattern("d/M/yyyy"),
                DateTimeFormatter.ofPattern("M/d/yyyy"),
                DateTimeFormatter.ofPattern("yyyy/M/d"),
                DateTimeFormatter.ofPattern("d-M-yyyy"),
                DateTimeFormatter.ofPattern("M-d-yyyy"),
                DateTimeFormatter.ofPattern("yyyy-M-d"),
                DateTimeFormatter.ofPattern("d MMM yyyy"),
                DateTimeFormatter.ofPattern("MMM d, yyyy"),
                DateTimeFormatter.ofPattern("d MMMM yyyy"),
                DateTimeFormatter.ofPattern("yyyyMMdd")
        );

        for (DateTimeFormatter formatter : dateTimeFormatters) {
            try {
                return LocalDateTime.parse(dateString, formatter);
            } catch (DateTimeParseException e) {
                // Continue to try the next format
            }
        }

        for (DateTimeFormatter formatter : dateFormatters) {
            try {
                return LocalDate.parse(dateString, formatter).atStartOfDay();
            } catch (DateTimeParseException e) {
                // Continue to try the next format
            }
        }
        throw new DukeException("Invalid Date and time format");
    }

Example from src/main/java/services/parser/Parser.java lines 260-303:

    public static Task parseTaskFromString(String taskString) throws DukeException {
        assert taskString != null && !taskString.isEmpty() : "taskString cannot be null or empty";
        String[] parts = taskString.split(" \\| ");
        assert parts.length >= 3 : "Task string format is invalid";
        String taskType = parts[0];
        boolean isDone = parts[1].trim().equals("1");
        String description = parts[2].trim();
        String additionalInfo = parts.length > 3 ? parts[3].trim() : null;
        switch (taskType) {
        case "T":
            ToDo todo = new ToDo(description);
            if (isDone) {
                todo.markAsDone();
            }
            return todo;
        case "D":
            if (additionalInfo == null) {
                throw new DukeException("Invalid tasks.Deadline format in file");
            }
            LocalDateTime by = LocalDateTime.parse(additionalInfo);
            Deadline deadline = new Deadline(description, by);
            if (isDone) {
                deadline.markAsDone();
            }
            return deadline;
        case "E":
            String[] times = additionalInfo.split(" to ");
            if (times.length < 2) {
                throw new DukeException("Invalid tasks.Event time format in file.");
            }
            LocalDateTime start = LocalDateTime.parse(times[0].trim());
            LocalDateTime end = LocalDateTime.parse(times[1].trim());

            Event event = new Event(description, start, end);
            if (isDone) {
                event.markAsDone();
            }

            return event;

        default:
            return null;
        }
    }

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 ee190cf:


Done C-DetectDuplicates

This commit introduces a significant enhancement to the project to
filter for duplicates.

Added isDuplicateTask method in TaskList.
   - For Deadline tasks, it checks for duplicates based on both name and deadline time.
   - For Event tasks, it verifies if either the start or end time, along with the task name, is identical to an existing task.
   - For other task types, a simple name-based comparison is performed.

Modified the addTask method to prevent addition of duplicate tasks.


  • body not wrapped at 72 characters: e.g., - For Deadline tasks, it checks for duplicates based on both name and deadline time.

possible problems in commit 8c00bb0:


Done A-Asssertions

In this commit, assertions have been integrated into the project to improve the overall reliability and maintainability of the code. These additions are focused on ensuring that key assumptions in the codebase are explicitly checked during runtime.


  • body not wrapped at 72 characters: e.g., In this commit, assertions have been integrated into the project to improve the overall reliability and maintainability of the code. These additions are focused on ensuring that key assumptions in the codebase are explicitly checked during runtime.

possible problems in commit 58622c3:


Implement Assertions in Various Classes

This commit introduces the use of Java assertions across multiple classes in the project to validate assumptions about the program's state. Assertions are added to ensure that the program operates under expected conditions, enhancing the robustness and reliability of the code during development.

Changes made:
1. TaskList Class:
        - Added assertions to check if task-related operations are
          performed with valid indices and non-null task objects.
2. Storage Class:
        - Inserted assertions to validate non-null task lists and the
          existence of the file after creation.
3: Parser Class:
        - Added assertions in date parsing methods to ensure non-null
          and properly formatted date strings.
        - Implemented assertions to verify non-empty and non-null user
          input strings.


  • body not wrapped at 72 characters: e.g., This commit introduces the use of Java assertions across multiple classes in the project to validate assumptions about the program's state. Assertions are added to ensure that the program operates under expected conditions, enhancing the robustness and reliability of the code during development.

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.

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.