Restuta/rcn.io

View on GitHub
src/client/admin/events/CreateEventId.jsx

Summary

Maintainability
D
1 day
Test Coverage

Function render has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const {
      year,
      prefix,
      name,
Severity: Major
Found in src/client/admin/events/CreateEventId.jsx - About 4 hrs to fix

Unexpected 'todo bc' comment.
Open

/* TODO BC:

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/

TODO found
Open

/* TODO BC:

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

          <div className="form-group">
            <label htmlFor="input-year">Prefix</label>
            <input id="input-prefix"
              type="text"
              style={{width: '16rem'}}
Severity: Major
Found in src/client/admin/events/CreateEventId.jsx and 1 other location - About 4 hrs to fix
src/client/admin/events/CreateEventId.jsx on lines 165..176

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

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

          <div className="form-group">
            <label htmlFor="input-year">Year</label>
            <input id="input-year"
              type="number"
              style={{width: '10rem'}}
Severity: Major
Found in src/client/admin/events/CreateEventId.jsx and 1 other location - About 4 hrs to fix
src/client/admin/events/CreateEventId.jsx on lines 177..188

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

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

There are no issues that match your filters.

Category
Status