jelhan/croodle

View on GitHub

Showing 38 of 52 total issues

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

                      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

                        Function validate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          validate(value, options, model, attribute) {
                            assert(
                              'options.parent is required',
                              isPresent(options.parent)
                            );
                        Severity: Minor
                        Found in app/validators/unique.js - About 1 hr to fix

                          Function submit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              async submit() {
                                if (!this.get('validations.isValid')) {
                                  return;
                                }
                          
                          
                          Severity: Minor
                          Found in app/controllers/poll/participation.js - About 1 hr to fix

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

                              selections: computed('options', 'pollController.dates', function() {
                                let options = this.options;
                                let isFindADate = this.isFindADate;
                                let lastDate;
                            
                            
                            Severity: Minor
                            Found in app/controllers/poll/participation.js - About 1 hr to fix

                              Function submit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                @action
                                async submit() {
                                  if (!this.validations.isValid) {
                                    return;
                                  }
                              Severity: Minor
                              Found in app/controllers/create/settings.js - About 1 hr to fix

                                Function restoreLegacySupportHook has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
                                Found in api/classes/user.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 deleteDirRecursively has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private function deleteDirRecursively($dir) {
                                    if (substr($dir, -1) !== '/') {
                                      throw new Exception('dir has to end on /');
                                    }
                                
                                
                                Severity: Minor
                                Found in api/classes/poll.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