BerniWittmann/spielplanismaning

View on GitHub
src/models/Spiele.js

Summary

Maintainability
F
4 days
Test Coverage

File Spiele.js has 416 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const async = require('async');
const _ = require('lodash');
const cls = require('../config/cls.js');
Severity: Minor
Found in src/models/Spiele.js - About 6 hrs to fix

    Function setToreNormal has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    SpielSchema.methods.setToreNormal = function (toreA, toreB, cb) {
        const beachEventID = cls.getBeachEventID();
        const clsSession = cls.getNamespace();
        const self = this;
        return clsSession.run(function () {
    Severity: Major
    Found in src/models/Spiele.js - About 2 hrs to fix

      Function setToreComplex has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      SpielSchema.methods.setToreComplex = function (data, cb) {
          if (!data.complex || !data.complex.hz1 || !data.complex.hz2) {
              return cb(new Error('Keine Halbzeit Daten gefunden'));
          }
      
      
      Severity: Minor
      Found in src/models/Spiele.js - About 1 hr to fix

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

        SpielSchema.methods.reset = function (cb) {
            const beachEventID = cls.getBeachEventID();
            const clsSession = cls.getNamespace();
            const self = this;
            return clsSession.run(function () {
        Severity: Minor
        Found in src/models/Spiele.js - About 1 hr to fix

          Function setPunkte has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          SpielSchema.methods.setPunkte = function (punkteA, punkteB, cb) {
              const beachEventID = cls.getBeachEventID();
              const clsSession = cls.getNamespace();
              const self = this;
              return clsSession.run(function () {
          Severity: Minor
          Found in src/models/Spiele.js - About 1 hr to fix

            Function resetPunkte has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            SpielSchema.methods.resetPunkte = function (cb) {
                const beachEventID = cls.getBeachEventID();
                const clsSession = cls.getNamespace();
                const self = this;
                return clsSession.run(function () {
            Severity: Minor
            Found in src/models/Spiele.js - About 1 hr to fix

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

              SpielSchema.methods.setToreA = function (toreA, cb) {
                  const beachEventID = cls.getBeachEventID();
                  const clsSession = cls.getNamespace();
                  const self = this;
                  return clsSession.run(function () {
              Severity: Major
              Found in src/models/Spiele.js and 3 other locations - About 3 hrs to fix
              src/models/Spiele.js on lines 303..314
              src/models/Spiele.js on lines 385..396
              src/models/Spiele.js on lines 398..409

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

              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 4 locations. Consider refactoring.
              Open

              SpielSchema.methods.setPunkteB = function (punkteB, cb) {
                  const beachEventID = cls.getBeachEventID();
                  const clsSession = cls.getNamespace();
                  const self = this;
                  return clsSession.run(function () {
              Severity: Major
              Found in src/models/Spiele.js and 3 other locations - About 3 hrs to fix
              src/models/Spiele.js on lines 290..301
              src/models/Spiele.js on lines 303..314
              src/models/Spiele.js on lines 385..396

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

              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 4 locations. Consider refactoring.
              Open

              SpielSchema.methods.setToreB = function (toreB, cb) {
                  const beachEventID = cls.getBeachEventID();
                  const clsSession = cls.getNamespace();
                  const self = this;
                  return clsSession.run(function () {
              Severity: Major
              Found in src/models/Spiele.js and 3 other locations - About 3 hrs to fix
              src/models/Spiele.js on lines 290..301
              src/models/Spiele.js on lines 385..396
              src/models/Spiele.js on lines 398..409

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

              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 4 locations. Consider refactoring.
              Open

              SpielSchema.methods.setPunkteA = function (punkteA, cb) {
                  const beachEventID = cls.getBeachEventID();
                  const clsSession = cls.getNamespace();
                  const self = this;
                  return clsSession.run(function () {
              Severity: Major
              Found in src/models/Spiele.js and 3 other locations - About 3 hrs to fix
              src/models/Spiele.js on lines 290..301
              src/models/Spiele.js on lines 303..314
              src/models/Spiele.js on lines 398..409

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

              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 (spiel.toreA > spiel.toreB) {
                                      return clsSession.run(function () {
                                          clsSession.set('beachEventID', beachEventID);
              
                                          spiel.setPunkte(2, 0, function (err, spiel) {
              Severity: Major
              Found in src/models/Spiele.js and 1 other location - About 3 hrs to fix
              src/models/Spiele.js on lines 127..155

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

              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

                                  } else if (spiel.toreA < spiel.toreB) {
                                      return clsSession.run(function () {
                                          clsSession.set('beachEventID', beachEventID);
              
                                          spiel.setPunkte(0, 2, function (err, spiel) {
              Severity: Major
              Found in src/models/Spiele.js and 1 other location - About 3 hrs to fix
              src/models/Spiele.js on lines 112..155

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

              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

                  complex: {
                      hz1: {
                          toreA: Number,
                          toreB: Number
                      },
              Severity: Minor
              Found in src/models/Spiele.js and 1 other location - About 30 mins to fix
              src/public/templates/event/spiel/spiel.ui.js on lines 74..87

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

              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