Code Monkey home page Code Monkey logo

duke's Introduction

duke's People

Contributors

damithc avatar j-lum avatar jiachen247 avatar metildachee avatar

duke's Issues

Sharing iP code quality feedback [for @metildachee]

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

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 71-142:

    public static void main(String[] args) {
        System.out.println(STMT_START);
        Scanner in = new Scanner(System.in);
        ArrayList<Task> list = new ArrayList<>();
        String input = in.nextLine();
        ArrayList<String> tokens = new ArrayList(Arrays.asList(input.split(" ")));
        String instruction = tokens.get(0);
        Integer id = 0;
        String taskInfo = tokens // TODO: Fix this (duh)
                .subList(1, tokens.size())
                .toString()
                .replace(",", "")
                .replace("[", "")
                .replace("]", "")
                .trim();

        while (!instruction.toLowerCase(Locale.ROOT).equals(DETECT_END)) {
            if (instruction.toLowerCase(Locale.ROOT).equals(DETECT_LIST)) {
                try {
                    list(list);
                } catch (Exception e) {
                    printErrorMessage(Message.EMPTY_LIST);
                }
            } else if (instruction.toLowerCase(Locale.ROOT).equals(DETECT_DONE) && tokens.size() >= 2) {
                markDone(list, Integer.parseInt((tokens.get(1))));
            } else if (instruction.toLowerCase(Locale.ROOT).equals(DETECT_DELETE) && tokens.size() >= 2) {
                try {
                    markDelete(list, Integer.parseInt((tokens.get(1))));
                } catch (Exception e) {
                    printErrorMessage(Message.UNKNOWN_OBJECT);
                }

            } else {
                Task task = null;
                switch (instruction) {
                    case DETECT_ADD_TODO:
                        task = new Todo(taskInfo, id);
                        break;
                    case DETECT_ADD_EVENT:
                        ArrayList<String> addInfo = new ArrayList(Arrays.asList(taskInfo.split("/at")));
                        task = new Event(addInfo.get(0), addInfo.get(1), id);
                        break;
                    case DETECT_ADD_DEADLINE:
                        ArrayList<String> deadlineInfo = new ArrayList(Arrays.asList(taskInfo.split("/by")));
                        task = new Deadline(deadlineInfo.get(0), deadlineInfo.get(1), id);
                        break;
                }

                try {
                    add(list, task);
                } catch (Exception e) {
                    printErrorMessage(Message.ERROR_UNRECOGNISED);
                }
            }

            input = in.nextLine();
            System.out.println("input: " + input);
            tokens = new ArrayList(Arrays.asList(input.split(" ")));
            instruction = tokens.get(0);
            System.out.println("instruction: " + instruction);
            taskInfo = tokens
                    .subList(1, tokens.size())
                    .toString()
                    .replace(",", "")
                    .replace("[", "")
                    .replace("]", "")
                    .trim();
            System.out.println("task info:" + taskInfo);
            id = list.size();
        }
        System.out.println(STMT_END);
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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 ๐Ÿ‘

โ„น๏ธ The bot account @nus-se-bot 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 @metildachee] - Round 2

@metildachee 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/main/java/Duke.java lines 71-142:

    public static void main(String[] args) {
        System.out.println(STMT_START);
        Scanner in = new Scanner(System.in);
        ArrayList<Task> list = new ArrayList<>();
        String input = in.nextLine();
        ArrayList<String> tokens = new ArrayList(Arrays.asList(input.split(" ")));
        String instruction = tokens.get(0);
        Integer id = 0;
        String taskInfo = tokens // TODO: Fix this (duh)
                .subList(1, tokens.size())
                .toString()
                .replace(",", "")
                .replace("[", "")
                .replace("]", "")
                .trim();

        while (!instruction.toLowerCase(Locale.ROOT).equals(DETECT_END)) {
            if (instruction.toLowerCase(Locale.ROOT).equals(DETECT_LIST)) {
                try {
                    list(list);
                } catch (Exception e) {
                    printErrorMessage(Message.EMPTY_LIST);
                }
            } else if (instruction.toLowerCase(Locale.ROOT).equals(DETECT_DONE) && tokens.size() >= 2) {
                markDone(list, Integer.parseInt((tokens.get(1))));
            } else if (instruction.toLowerCase(Locale.ROOT).equals(DETECT_DELETE) && tokens.size() >= 2) {
                try {
                    markDelete(list, Integer.parseInt((tokens.get(1))));
                } catch (Exception e) {
                    printErrorMessage(Message.UNKNOWN_OBJECT);
                }

            } else {
                Task task = null;
                switch (instruction) {
                    case DETECT_ADD_TODO:
                        task = new Todo(taskInfo, id);
                        break;
                    case DETECT_ADD_EVENT:
                        ArrayList<String> addInfo = new ArrayList(Arrays.asList(taskInfo.split("/at")));
                        task = new Event(addInfo.get(0), addInfo.get(1), id);
                        break;
                    case DETECT_ADD_DEADLINE:
                        ArrayList<String> deadlineInfo = new ArrayList(Arrays.asList(taskInfo.split("/by")));
                        task = new Deadline(deadlineInfo.get(0), deadlineInfo.get(1), id);
                        break;
                }

                try {
                    add(list, task);
                } catch (Exception e) {
                    printErrorMessage(Message.ERROR_UNRECOGNISED);
                }
            }

            input = in.nextLine();
            System.out.println("input: " + input);
            tokens = new ArrayList(Arrays.asList(input.split(" ")));
            instruction = tokens.get(0);
            System.out.println("instruction: " + instruction);
            taskInfo = tokens
                    .subList(1, tokens.size())
                    .toString()
                    .replace(",", "")
                    .replace("[", "")
                    .replace("]", "")
                    .trim();
            System.out.println("task info:" + taskInfo);
            id = list.size();
        }
        System.out.println(STMT_END);
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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 ๐Ÿ‘

โ„น๏ธ The bot account @nus-se-bot 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.