jordansne/ntwitbot

View on GitHub

Showing 10 of 12 total issues

Function retrieveForNew has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    retrieveForNew(params, tweetsLeft, tweetsRetrieved) {
        // Copy object to allow for proper unit testing
        const request = Object.assign({}, params);

        // If first request..
Severity: Major
Found in src/retrieve.js - About 2 hrs to fix

    Function retrieveForExisting has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        retrieveForExisting(params, tweetsRetrieved) {
            // Copy object to allow for proper unit testing
            const request = Object.assign({}, params);
            const firstReq = !request.hasOwnProperty('max_id');
    
    
    Severity: Minor
    Found in src/retrieve.js - About 1 hr to fix

      Function generateTweet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          generateTweet(wordDB) {
              let wordStack, firstWord = 0;
              const firstWords = this.getFirstWords(wordDB);
      
              let done = false;
      Severity: Minor
      Found in src/generate.js - About 1 hr to fix

        Function generateTweet has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

            generateTweet(wordDB) {
                let wordStack, firstWord = 0;
                const firstWords = this.getFirstWords(wordDB);
        
                let done = false;
        Severity: Minor
        Found in src/generate.js - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function getPossibleMoves has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

            getPossibleMoves(wordDB, wordStack) {
                const nextMoves = [];
                const key = this.keyOf(wordStack);
        
                if (wordStack.length === 0) {
        Severity: Minor
        Found in src/generate.js - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    console.error(`${this.getFormattedTime()} ${' ERROR '.black.bgRed}${' %s'.red}`, message);
        Severity: Minor
        Found in src/utils.js and 1 other location - About 40 mins to fix
        src/utils.js on lines 56..56

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 48.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    console.log(`${this.getFormattedTime()} ${' DEBUG '.black.bgCyan}${' %s'.cyan}`, message);
        Severity: Minor
        Found in src/utils.js and 1 other location - About 40 mins to fix
        src/utils.js on lines 41..41

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 48.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                return this.readFile(this.STATE_FILE).then((data) => {
                    try {
                        return JSON.parse(data);
                    } catch (error) {
                        Utils.logError('I/O: Failed to parse state data');
        Severity: Minor
        Found in src/data.js and 1 other location - About 35 mins to fix
        src/data.js on lines 91..98

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 46.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                return this.readFile(this.DATABASE_FILE).then((data) => {
                    try {
                        return JSON.parse(data);
                    } catch (error) {
                        Utils.logError('I/O: Failed to parse database data');
        Severity: Minor
        Found in src/data.js and 1 other location - About 35 mins to fix
        src/data.js on lines 120..127

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 46.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Unexpected 'todo' comment.
        Open

                        // TODO Determine if retryable and retry/exit depending on result
        Severity: Minor
        Found in src/main.js by eslint

        Disallow Warning Comments (no-warning-comments)

        Developers often add comments to code which is not complete or needs review. Most likely you want to fix or review the code, and then remove the comment, before you consider the code to be production ready.

        // TODO: do something
        // FIXME: this is not a good idea

        Rule Details

        This rule reports comments that include any of the predefined terms specified in its configuration.

        Options

        This rule has an options object literal:

        • "terms": optional array of terms to match. Defaults to ["todo", "fixme", "xxx"]. Terms are matched case-insensitive and as whole words: fix would match FIX but not fixing. Terms can consist of multiple words: really bad idea.
        • "location": optional string that configures where in your comments to check for matches. Defaults to "start". The other value is match anywhere in comments.

        Example of incorrect code for the default { "terms": ["todo", "fixme", "xxx"], "location": "start" } options:

        /*eslint no-warning-comments: "error"*/
        
        function callback(err, results) {
          if (err) {
            console.error(err);
            return;
          }
          // TODO
        }

        Example of correct code for the default { "terms": ["todo", "fixme", "xxx"], "location": "start" } options:

        /*eslint no-warning-comments: "error"*/
        
        function callback(err, results) {
          if (err) {
            console.error(err);
            return;
          }
          // NOT READY FOR PRIME TIME
          // but too bad, it is not a predefined warning term
        }

        terms and location

        Examples of incorrect code for the { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } options:

        /*eslint no-warning-comments: ["error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }]*/
        
        // TODO: this
        // todo: this too
        // Even this: TODO
        /* /*
         * The same goes for this TODO comment
         * Or a fixme
         * as well as any other term
         */

        Examples of correct code for the { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } options:

        /*eslint no-warning-comments: ["error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }]*/
        
        // This is to do
        // even not any other    term
        // any other terminal
        /*
         * The same goes for block comments
         * with any other interesting term
         * or fix me this
         */

        When Not To Use It

        • If you have a large code base that was not developed with a policy to not use such warning terms, you might get hundreds of warnings / errors which might be counter-productive if you can't fix all of them (e.g. if you don't get the time to do it) as you might overlook other warnings / errors or get used to many of them and don't pay attention on it anymore.
        • Same reason as the point above: You shouldn't configure terms that are used very often (e.g. central parts of the native language used in your comments). Source: http://eslint.org/docs/rules/
        Severity
        Category
        Status
        Source
        Language