MaazAli/phanime

View on GitHub
packages/phanime-mal-import/server/methods/getUserList.js

Summary

Maintainability
D
1 day
Test Coverage

Function getMALUserList has 167 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    getMALUserList: function(xmlContent) {

        // The user must be logged in for this function
        if (!Meteor.user())
            throw new Meteor.Error('user-required', 'User must be logged in to import MAL list');
Severity: Major
Found in packages/phanime-mal-import/server/methods/getUserList.js - About 6 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                    if (!anime.series_title || !anime.series_animedb_id || !anime.my_watched_episodes || !anime.my_start_date || !anime.my_finish_date || !anime.my_score || !anime.my_status || !anime.my_rewatching || !anime.my_comments)
                        throw new Meteor.Error('mal-import-failed', 'XML file format is different than expected');
    Severity: Critical
    Found in packages/phanime-mal-import/server/methods/getUserList.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                                          if (animeId && coverImageUrl) {
                                              console.log('We\'re about to upload the image');
                                              Meteor.call("uploadImageFromUrl", coverImageUrl, 'anime', 'cover', animeId, function(error, result) {
                                                  if (error) {
                                                      throw new Meteor.Error(403, error.reason);
      Severity: Major
      Found in packages/phanime-mal-import/server/methods/getUserList.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                            if (LibraryEntries.simpleSchema().namedContext().validate(libraryEntry) === false) {
                                                // if validation failed, we should continue on with adding the entries, but we should push the invalid keys object into an array.
                                                importStats.failedImports++;
        
                                                var invalidKeys = LibraryEntries.simpleSchema().namedContext().invalidKeys();
        Severity: Major
        Found in packages/phanime-mal-import/server/methods/getUserList.js - About 45 mins to fix

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

                                  if (LibraryEntries.simpleSchema().namedContext().validate(libraryEntry) === false) {
                                      // if validation failed, we should continue on with adding the entries, but we should push the invalid keys object into an array.
                                      importStats.failedImports++;
          
                                      var invalidKeys = LibraryEntries.simpleSchema().namedContext().invalidKeys();
          Severity: Major
          Found in packages/phanime-mal-import/server/methods/getUserList.js and 1 other location - About 2 hrs to fix
          packages/phanime-mal-import/server/methods/getUserList.js on lines 232..258

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

          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

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

                                              if (LibraryEntries.simpleSchema().namedContext().validate(libraryEntry) === false) {
                                                  // if validation failed, we should continue on with adding the entries, but we should push the invalid keys object into an array.
                                                  importStats.failedImports++;
          
                                                  var invalidKeys = LibraryEntries.simpleSchema().namedContext().invalidKeys();
          Severity: Major
          Found in packages/phanime-mal-import/server/methods/getUserList.js and 1 other location - About 2 hrs to fix
          packages/phanime-mal-import/server/methods/getUserList.js on lines 127..153

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

          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