Noosfero/noosfero

View on GitHub
plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js

Summary

Maintainability
F
6 days
Test Coverage

Function socialSharePrivacy has 303 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function socialSharePrivacy (options) {

        if (typeof options === "string") {
            var command = options;
            if (arguments.length === 1) {

    File socialshareprivacy.js has 639 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @license
     * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz
     *
     * http://www.heise.de/extras/socialshareprivacy/

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

          function absurl (url, base) {
              if (!base) base = document.baseURI || $("html > head > base").last().attr("href") || document.location.href;
              if (!url) {
                  return base;
              }

        Consider simplifying this complex logical expression.
        Open

                    if (arguments.length === 1) {
                        switch (command) {
                            case "enable":
                                this.find('.switch.off').click();
                                break;

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

              function buttonClickHandler (service_name) {
                  function onclick (event) {
                      var $container = $(this).parents('li.help_info').first();
                      var $share = $container.parents('.social_share_privacy_area').first().parent();
                      var options = $share.data('social-share-privacy-options');

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

                    function onclick (event) {
                        var $container = $(this).parents('li.help_info').first();
                        var $share = $container.parents('.social_share_privacy_area').first().parent();
                        var options = $share.data('social-share-privacy-options');
                        var service = options.services[service_name];

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

                  function formatNumber (number) {
                      number = Number(number);
              
                      var prefix = "";
                      var suffix = "";

                Avoid deeply nested control flow statements.
                Open

                                            if (typeof ctx === "string") {
                                                ctx = (new Function("$", "return ("+ctx+");")).call(this, $);
                                            }

                  Avoid deeply nested control flow statements.
                  Open

                                              if (perma) {
                                                  $context.find('li.'+class_name+' span.switch').click();
                                                  this_options.set_perma_option(service_name, this_options);
                                              }

                    Avoid too many return statements within this function.
                    Open

                            return this.each(function () {
                                // parse options passed via data-* attributes:
                                var data = {};
                                if (this.lang) data.language = this.lang;
                                for (var i = 0, attrs = this.attributes; i < attrs.length; ++ i) {

                      Avoid too many return statements within this function.
                      Open

                                              return this.find('.'+(options.services[arg].class_name||arg)+' .switch').hasClass('off');

                        Avoid too many return statements within this function.
                        Open

                                    return base.replace(/[\?#].*$/,'')+url;

                          Avoid too many return statements within this function.
                          Open

                                          return /^[^:]+:\/*[^\/]+/i.exec(base)[0]+url;

                            Avoid too many return statements within this function.
                            Open

                                        return base.replace(/#.*$/,'')+url;

                              Avoid too many return statements within this function.
                              Open

                                          return base+path.join("/");

                                Avoid too many return statements within this function.
                                Open

                                            return this;

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

                                                      case "enabled":
                                                          var enabled = {};
                                                          this.each(function () {
                                                              var $self = $(this);
                                                              var options = $self.data('social-share-privacy-options');
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 441..450

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

                                  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

                                                      case "disabled":
                                                          var disabled = {};
                                                          this.each(function () {
                                                              var $self = $(this);
                                                              var options = $self.data('social-share-privacy-options');
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 430..439

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

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

                                                      case "disable":
                                                          this.each(function () {
                                                              var $self = $(this);
                                                              var options = $self.data('social-share-privacy-options');
                                                              $self.find('.'+(options.services[arg].class_name||arg)+' .switch.on').click();
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 459..465
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 475..481

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

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

                                                      case "toggle":
                                                          this.each(function () {
                                                              var $self = $(this);
                                                              var options = $self.data('social-share-privacy-options');
                                                              $self.find('.'+(options.services[arg].class_name||arg)+' .switch').click();
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 459..465
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 467..473

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

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

                                                      case "enable":
                                                          this.each(function () {
                                                              var $self = $(this);
                                                              var options = $self.data('social-share-privacy-options');
                                                              $self.find('.'+(options.services[arg].class_name||arg)+' .switch.off').click();
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 467..473
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 475..481

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

                                  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

                                                      case "disabled":
                                                          var options = this.data('social-share-privacy-options');
                                                          return this.find('.'+(options.services[arg].class_name||arg)+' .switch').hasClass('off');
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 500..502

                                  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

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

                                                      case "enabled":
                                                          var options = this.data('social-share-privacy-options');
                                                          return this.find('.'+(options.services[arg].class_name||arg)+' .switch').hasClass('on');
                                  plugins/social_share_privacy/public/socialshareprivacy/javascripts/socialshareprivacy.js on lines 504..506

                                  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

                                  There are no issues that match your filters.

                                  Category
                                  Status