boxuk/commit-message-checker

View on GitHub

Showing 6 of 6 total issues

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

    lib.validateCommitMessagesFromSHARange(commitRange)
        .catch(error => {
            // If we failed to get the commit messages then fail the build
            console.error(`Failed to retrieve commit messages: ${error}`);

Severity: Major
Found in tools/travis-commit-message-checker.js and 1 other location - About 4 hrs to fix
tools/appveyor-commit-message-checker.js on lines 16..33

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 134.

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

    lib.validateCommitMessagesFromSHARange(commitRange)
        .catch(error => {
            // If we failed to get the commit messages then fail the build
            console.error(`Failed to retrieve commit messages: ${error}`);

Severity: Major
Found in tools/appveyor-commit-message-checker.js and 1 other location - About 4 hrs to fix
tools/travis-commit-message-checker.js on lines 13..30

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 134.

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

if (isPullRequest) {
    const baseBranch = process.env.APPVEYOR_REPO_BRANCH;

    // For the commit range, we need to get all commits since the base branch, up to the current HEAD.
    const commitRange = `${baseBranch}..HEAD`;
Severity: Major
Found in tools/appveyor-commit-message-checker.js and 1 other location - About 4 hrs to fix
tools/travis-commit-message-checker.js on lines 10..50

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 128.

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

if (isPullRequest) {
    const commitRange = process.env.TRAVIS_COMMIT_RANGE;

    lib.validateCommitMessagesFromSHARange(commitRange)
        .catch(error => {
Severity: Major
Found in tools/travis-commit-message-checker.js and 1 other location - About 4 hrs to fix
tools/appveyor-commit-message-checker.js on lines 10..55

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 128.

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

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

function buildTable (validationResult) {
    const rows = [];

    if (validationResult.isValid) {
        // For valid commit messages we have nothing to show
Severity: Minor
Found in reporter/table-reporter.js - About 1 hr to fix

    Unexpected 'todo' comment.
    Open

    // TODO: This rule should be replaced with more granular rules.
    Severity: Minor
    Found in lib/rules/valid-summary-rule.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