jelhan/croodle

View on GitHub

Showing 52 of 52 total issues

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

      datasets.push({
        label: this.intl.t('answerTypes.maybe.label').toString(),
        backgroundColor: 'rgba(220,220,220,0.5)',
        borderColor: 'rgba(220,220,220,0.8)',
        hoverBackgroundColor: 'rgba(220,220,220,0.75)',
Severity: Major
Found in app/components/poll-evaluation-chart.js and 1 other location - About 3 hrs to fix
app/components/poll-evaluation-chart.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 98.

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

    datasets.push({
      label: this.intl.t('answerTypes.yes.label').toString(),
      backgroundColor: 'rgba(151,187,205,0.5)',
      borderColor: 'rgba(151,187,205,0.8)',
      hoverBackgroundColor: 'rgba(151,187,205,0.75)',
Severity: Major
Found in app/components/poll-evaluation-chart.js and 1 other location - About 3 hrs to fix
app/components/poll-evaluation-chart.js on lines 104..111

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

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

  protected function restoreLegacySupportHook(&$data) {
    if (!isset($data->version) || $data->version === 'v0.3-0') {
      if (isset($data->user) && is_object($data->user)) {
        $data = $data->user;
      }
Severity: Major
Found in api/classes/user.php and 1 other location - About 2 hrs to fix
api/classes/poll.php on lines 130..144

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

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

  protected function restoreLegacySupportHook(&$data) {
    if (!isset($data->version) || $data->version === 'v0.3-0') {
      if (isset($data->poll) && is_object($data->poll)) {
        $data = $data->poll;
      }
Severity: Major
Found in api/classes/poll.php and 1 other location - About 2 hrs to fix
api/classes/user.php on lines 78..92

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

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 save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  public function save() {
    // create dir for data if it does not exists
    $counter = 0;
    while (true) {
      $this->set('id', $this->generateNewId());
Severity: Minor
Found in api/classes/model.php - About 2 hrs 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 normalize has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  normalize(payload) {
    let [type] = Object.keys(payload);
    let attrs = payload[type];
    let { belongsToAssociations, hasManyAssociations } = this.registry.schema._registry[type].class.prototype;

Severity: Minor
Found in mirage/serializers/application.js - About 1 hr to fix

    Function bestOptions has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @computed('users.[]')
      get bestOptions() {
        // can not evaluate answer type free text
        if (this.get('poll.isFreeText')) {
          return undefined;
    Severity: Minor
    Found in app/components/poll-evaluation-summary.js - About 1 hr to fix

      Function adoptTimesOfFirstDay has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        @action
        adoptTimesOfFirstDay() {
          const dates = this.dates;
          const datesForFirstDay = this.datesForFirstDay;
          const timesForFirstDay = this.timesForFirstDay;
      Severity: Minor
      Found in app/components/create-options-datetime.js - About 1 hr to fix

        Function data has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          @computed('users.[]', 'options.{[],each.title}', 'currentLocale')
          get data() {
            let labels = this.options.map((option) => {
              let value = get(option, 'title');
              if (!this.isFindADate) {
        Severity: Minor
        Found in app/components/poll-evaluation-chart.js - About 1 hr to fix

          Method restore has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static function restore($id) {
              if (!static::isValidId($id)) {
                throw new Exception($id . ' is not a valid id');
              }
          
          
          Severity: Minor
          Found in api/classes/model.php - About 1 hr to fix

            Function evaluation has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              @computed('users.[]')
              get evaluation() {
                if (!this.isEvaluable) {
                  return [];
                }
            Severity: Minor
            Found in app/controllers/poll/evaluation.js - About 1 hr to fix

              Function exports has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function(defaults) {
                let app = new EmberApp(defaults, {
                  autoImport: {
                    forbidEval: true,
                    webpack: {
              Severity: Minor
              Found in ember-cli-build.js - About 1 hr to fix

                Function default has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function(answerType) {
                  switch (answerType) {
                    case 'YesNo':
                      return [
                        {
                Severity: Minor
                Found in app/utils/answers-for-answer-type.js - About 1 hr to fix

                  Method save has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public function save() {
                      // create dir for data if it does not exists
                      $counter = 0;
                      while (true) {
                        $this->set('id', $this->generateNewId());
                  Severity: Minor
                  Found in api/classes/model.php - About 1 hr to fix

                    Function postBuild has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      postBuild(result) {
                        let environment = this.app.env;
                    
                        // do not include app if build is for testing purposes only
                        if (environment === 'test') {
                    Severity: Minor
                    Found in lib/include-api-in-build/index.js - About 1 hr to fix

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

                          let yes = this.users.map(({ selections }) => {
                            return selections.map(({ type }) => type === 'yes' ? 1 : 0);
                          });
                      Severity: Major
                      Found in app/components/poll-evaluation-chart.js and 1 other location - About 1 hr to fix
                      app/components/poll-evaluation-chart.js on lines 101..103

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

                      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

                            let maybe = this.users.map(({ selections }) => {
                              return selections.map(({ type }) => type === 'maybe' ? 1 : 0);
                            });
                      Severity: Major
                      Found in app/components/poll-evaluation-chart.js and 1 other location - About 1 hr to fix
                      app/components/poll-evaluation-chart.js on lines 88..90

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

                      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 chartOptions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        @computed
                        get chartOptions() {
                          return {
                            legend: {
                              display: false
                      Severity: Minor
                      Found in app/components/poll-evaluation-chart.js - About 1 hr to fix

                        Function restore has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          public static function restore($id) {
                            if (!static::isValidId($id)) {
                              throw new Exception($id . ' is not a valid id');
                            }
                        
                        
                        Severity: Minor
                        Found in api/classes/model.php - About 1 hr 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 isValidSJCL has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private static function isValidSJCL($jsonstring) {
                            $accepted_keys=array('iv','v','iter','ks','ts','mode','adata','cipher','salt','ct');
                        
                            // Make sure content is valid json
                            $decoded = json_decode($jsonstring);
                        Severity: Minor
                        Found in api/classes/model.php - About 1 hr 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

                        Severity
                        Category
                        Status
                        Source
                        Language