lagranovskiy/j316-translator

View on GitHub

Showing 97 of 97 total issues

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

                if (!socket.handshake.session.clientAuthenticatedOn ||
                    new Date().getTime() - socket.handshake.session.clientAuthenticatedOn > 1000 * 60 * config.maxWaitingTime) {
                    // If a client forgot to logout then force logout after configured inactivity timeout of translator
                    if (new Date().getTime() - serviceDistributor.getLastActivity() > 1000 * 60 * config.inactiveTimeout) {
                        console.info('client :: no active translation session. Forcing disconnect of the client ' + socket.id);
Severity: Major
Found in app/connector/ConsumerConnector.js and 1 other location - About 1 hr to fix
app/connector/SenderConnector.js on lines 31..40

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

var yandexTranslator = function () {

    var service = {

        /**
Severity: Minor
Found in app/provider/connectors/YandexConnector.js - About 1 hr to fix

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

    module.exports = function(app) {
    
    
        var errorHandler = function(err, req, res, next) {
            console.error(err.stack);
    Severity: Minor
    Found in app/router.js - About 1 hr to fix

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

                  navigator.wakeLock.request("system").then(
                      function successFunction() {
                          $log.info('Preventing system to sleep is enabled');
                      },
                      function errorFunction() {
      Severity: Major
      Found in public/consumer/js/controllers/TranslationController.js and 1 other location - About 1 hr to fix
      public/consumer/js/controllers/TranslationController.js on lines 158..164

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

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

      var postmarkConnector = function() {
      
          var client = new postmark.Client(config.keys.postmark.apiToken);
      
          var service = {
      Severity: Minor
      Found in app/provider/connectors/PostmarkConnector.js - About 1 hr to fix

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

            submitQuestionAnswer: function (answer, questionUUID, senderName, senderLanguage) {
                var question = this.msgCache.get(questionUUID);
                if (!question) {
                    console.error('Cannot find msg with uuid ' + questionUUID + ' answer not accepted.');
                    return;
        Severity: Minor
        Found in app/business/QuestionDistributor.js - About 1 hr to fix

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

                      navigator.wakeLock.request("display").then(
                          function successFunction() {
                              $log.info('Preventing display to sleep is enabled');
                          },
                          function errorFunction() {
          Severity: Major
          Found in public/consumer/js/controllers/TranslationController.js and 1 other location - About 1 hr to fix
          public/consumer/js/controllers/TranslationController.js on lines 166..173

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

          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 (new Date().getTime() - serviceDistributor.getLastActivity() > 1000 * 60 * config.inactiveTimeout) {
                                  console.info('sender :: no active translation session. Forcing disconnect of the sender ' + socket.id);
                                  handleLogout();
                                  socket.handshake.session.save();
                                  socket.emit('authenticate');
          Severity: Major
          Found in app/connector/SenderConnector.js and 1 other location - About 1 hr to fix
          app/connector/ConsumerConnector.js on lines 31..39

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

          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 (new Date().getTime() - serviceDistributor.getLastActivity() > 1000 * 60 * config.inactiveTimeout) {
                                  console.info('client :: no active translation session. Forcing disconnect of the client ' + socket.id);
                                  handleLogout();
                                  socket.handshake.session.save();
                                  socket.emit('authenticate');
          Severity: Major
          Found in app/connector/ConsumerConnector.js and 1 other location - About 1 hr to fix
          app/connector/SenderConnector.js on lines 34..39

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

          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 (!newVal) {
                          //release() is used to release the lock.
                          if (navigator.wakeLock) {
                              navigator.wakeLock.release("display");
                              navigator.wakeLock.release("system");
          Severity: Major
          Found in public/consumer/js/controllers/TranslationController.js and 1 other location - About 1 hr to fix
          public/sender/js/controllers/TranslationController.js on lines 28..36

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

          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

                  $rootScope.$on('alreadyAuthenticated', function (event, data) {
                      registrationInfo.name = data.clientName;
                      registrationInfo.lang = data.clientLanguage;
                      isOnline = true;
                  });
          Severity: Major
          Found in public/consumer/js/service/TranslationService.js and 1 other location - About 1 hr to fix
          public/sender/js/service/TranslationService.js on lines 83..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 58.

          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 (newVal === false) {
                          //release() is used to release the lock.
                          if (navigator.wakeLock) {
                              navigator.wakeLock.release("display");
                              navigator.wakeLock.release("system");
          Severity: Major
          Found in public/sender/js/controllers/TranslationController.js and 1 other location - About 1 hr to fix
          public/consumer/js/controllers/TranslationController.js on lines 12..19

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

          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

                  $rootScope.$on('alreadyAuthenticated', function (event, data) {
                      registrationInfo.name = data.senderName;
                      registrationInfo.language = data.senderLanguage;
                      isOnline = true;
                  });
          Severity: Major
          Found in public/sender/js/service/TranslationService.js and 1 other location - About 1 hr to fix
          public/consumer/js/service/TranslationService.js on lines 44..48

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

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

                              var singleJob = function (jobCallback) {
                                  dbt.getVersInLang(damId, verseJob.bookId, verseJob.chapterId, verseJob.verseStart, verseJob.verseEnd,
                                      function (error, translatedArray) {
                                          if (error) {
                                              console.info('VerseWorker :: Cannot process verse lookup to ' + targetLanguage + ' for verse: ' + verse + ' : ' + error);
          Severity: Minor
          Found in app/provider/BibleVerseWorker.js - About 1 hr to fix

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

                    socket.on('error', function(err) {
                        if (err === 'handshake error') {
                            console.log('handshake error', err);
                        }
                        else {
            Severity: Major
            Found in app/connector/ConsumerConnector.js and 1 other location - About 1 hr to fix
            app/connector/SenderConnector.js on lines 19..26

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

            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

                    socket.on('error', function(err) {
                        if (err === 'handshake error') {
                            console.log('handshake error', err);
                        }
                        else {
            Severity: Major
            Found in app/connector/SenderConnector.js and 1 other location - About 1 hr to fix
            app/connector/ConsumerConnector.js on lines 16..23

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

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

            var dbtConnector = function () {
            
                var service = {
                    /**
                     * Returns vers with given parameters fetched from dbt.io
            Severity: Minor
            Found in app/provider/connectors/DbtConnector.js - 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 protokollService has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            var protokollService = function() {
            
                var controller = {
            
                    /**
            Severity: Minor
            Found in app/service/ProtokollService.js - 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 showSettings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    $scope.showSettings = function (ev) {
                        $mdDialog.show({
                                controller: function ($scope, $mdDialog) {
                                    $scope.settings = TranslationService.getSettings();
                                    $scope.hide = function () {
            Severity: Minor
            Found in public/consumer/js/controllers/NavController.js - About 1 hr to fix

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

                          translatorSocket.on('singinCompleted', function () {
                              $log.info('Registration completed');
                              isOnline = true;
                              defer.resolve();
                              translatorSocket.removeAllListeners('singinCompleted');
              Severity: Major
              Found in public/sender/js/service/TranslationService.js and 1 other location - About 1 hr to fix
              public/consumer/js/service/TranslationService.js on lines 26..31

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

              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

              Severity
              Category
              Status
              Source
              Language