lagranovskiy/j316-translator

View on GitHub

Showing 97 of 97 total issues

Function senderConnector has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

var senderConnector = function(socketChannel) {


    socketChannel.on('connection', function(socket) {

Severity: Minor
Found in app/connector/SenderConnector.js - About 1 day 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

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

        $scope.enterFullScreen = function () {
            var el = document.documentElement;
            if (!el) {
                return;
            }
Severity: Major
Found in public/consumer/js/controllers/NavController.js and 1 other location - About 7 hrs to fix
public/sender/js/controllers/NavController.js on lines 17..38

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

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

        $scope.enterFullScreen = function () {
            var el = document.documentElement;
            if (!el) {
                return;
            }
Severity: Major
Found in public/sender/js/controllers/NavController.js and 1 other location - About 7 hrs to fix
public/consumer/js/controllers/NavController.js on lines 71..95

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

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

var senderConnector = function(socketChannel) {


    socketChannel.on('connection', function(socket) {

Severity: Major
Found in app/connector/SenderConnector.js - About 7 hrs to fix

    Function consumerConnector has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    var consumerConnector = function (socketChannel) {
    
    
        /**
         * Socket server for handlich translation service
    Severity: Minor
    Found in app/connector/ConsumerConnector.js - About 6 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

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

            if (socket.handshake.session && socket.handshake.session.clientAuthenticated) {
                console.info('client :: Returning authenticated client ' + socket.id);
                initSubscribtions();
                socket.emit('alreadyAuthenticated', {
                    clientName: socket.handshake.session.clientName,
    Severity: Major
    Found in app/connector/ConsumerConnector.js and 1 other location - About 5 hrs to fix
    app/connector/SenderConnector.js on lines 45..57

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

    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 (socket.handshake.session && socket.handshake.session.senderAuthenticated) {
                console.info('sender :: Returning authenticated sender ' + socket.id);
                initSubscribtions();
                socket.emit('alreadyAuthenticated', {
                    senderName: socket.handshake.session.senderName,
    Severity: Major
    Found in app/connector/SenderConnector.js and 1 other location - About 5 hrs to fix
    app/connector/ConsumerConnector.js on lines 50..61

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

    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

            $scope.$on('cachedTranslations', function(event, msg) {
                _.each(msg, function(singleMsg) {
                    var displayableMessage = {
                        translation: singleMsg.translation,
                        sourceName: singleMsg.sourceName,
    Severity: Major
    Found in public/sender/js/controllers/TranslationController.js and 1 other location - About 5 hrs to fix
    public/consumer/js/controllers/TranslationController.js on lines 111..128

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

    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

            $scope.$on('cachedTranslations', function (event, msg) {
                _.each(msg, function (singleMsg) {
                    var displayableMessage = {
                        translation: singleMsg.translation,
                        sourceName: singleMsg.sourceName,
    Severity: Major
    Found in public/consumer/js/controllers/TranslationController.js and 1 other location - About 5 hrs to fix
    public/sender/js/controllers/TranslationController.js on lines 147..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 142.

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

    var consumerConnector = function (socketChannel) {
    
    
        /**
         * Socket server for handlich translation service
    Severity: Major
    Found in app/connector/ConsumerConnector.js - About 4 hrs to fix

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

                  if (socket.handshake.session) {
                      serviceDistributor.removeTranslationLanguage(socket.handshake.session.senderLanguage);
                      socket.leave('lang_' + socket.handshake.session.senderLanguage);
                      socket.handshake.session.senderAuthenticated = false;
                      delete socket.handshake.session.senderName;
      Severity: Major
      Found in app/connector/SenderConnector.js and 1 other location - About 4 hrs to fix
      app/connector/ConsumerConnector.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 124.

      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 (socket.handshake.session && socket.handshake.session.clientLanguage != undefined) {
                      serviceDistributor.removeTranslationLanguage(socket.handshake.session.clientLanguage);
                      socket.leave('lang_' + socket.handshake.session.clientLanguage);
                      socket.handshake.session.clientAuthenticated = false;
                      delete  socket.handshake.session.clientName;
      Severity: Major
      Found in app/connector/ConsumerConnector.js and 1 other location - About 4 hrs to fix
      app/connector/SenderConnector.js on lines 200..207

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

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

      var translationWorker = function () {
      
          var worker = {
      
      
      
      Severity: Major
      Found in app/provider/BibleVerseWorker.js - About 4 hrs to fix

        File TranslationController.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        angular.module('j316.translate.controller.translation', ['angular-underscore'])
            .controller('TranslationPanelCtrl', function($scope, $location, $timeout, $log, TranslationService, QuestionService, languages, $mdDialog, $mdMedia, $mdToast) {
        
                $scope.showLastMsgCount = 20;
                $scope.messages = [];
        Severity: Minor
        Found in public/sender/js/controllers/TranslationController.js - About 3 hrs to fix

          Function requestTranslation has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              requestTranslation: function (text, sourceLanguage, translationSource) {
                  if (!text) {
                      console.error('Service :: Cannot request a translation of null');
                      return;
                  }
          Severity: Major
          Found in app/business/ServiceDistributor.js - About 3 hrs to fix

            Function protocolService has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var protocolService = function() {
            
                var cache = new NodeCache({
                    stdTTL: 60 * 60 * 18,
                    checkperiod: 60 * 60 * 3
            Severity: Major
            Found in app/business/ProtokollDistributor.js - About 2 hrs to fix

              Function startVoiceRecognition has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      $scope.startVoiceRecognition = function() {
                          if (!('webkitSpeechRecognition' in window)) {
                              $log.log("webkitSpeechRecognition is not available");
                          }
                          else {
              Severity: Major
              Found in public/sender/js/controllers/TranslationController.js - About 2 hrs to fix

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

                            var displayableMessage = {
                                questionUUID: msg.questionUUID,
                                questionText: msg.questionText,
                                answerText: msg.answerText,
                                answerTranslation: msg.answerTranslation,
                Severity: Major
                Found in public/consumer/js/controllers/TranslationController.js and 1 other location - About 2 hrs to fix
                public/consumer/js/controllers/TranslationController.js on lines 89..97

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

                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

                            var displayableMessage = {
                                questionUUID: msg.questionUUID,
                                questionText: msg.questionText,
                                answerText: msg.answerText,
                                answerTranslation: msg.answerTranslation,
                Severity: Major
                Found in public/consumer/js/controllers/TranslationController.js and 1 other location - About 2 hrs to fix
                public/consumer/js/controllers/TranslationController.js on lines 64..72

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

                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

                        $scope.$on('socket:error', function(ev, data) {
                            $log.warn(data);
                            TranslationService.disconnect();
                
                            $mdToast.show(
                Severity: Major
                Found in public/sender/js/controllers/SenderController.js and 1 other location - About 2 hrs to fix
                public/sender/js/controllers/TranslationController.js on lines 166..176

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

                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