ejplatform/ej-server

View on GitHub

Showing 185 of 185 total issues

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

        disable: function(){
            var o = this.data('pagination');
            o.disabled = true;
            this.data('pagination', o);
            methods._draw.call(this);
Severity: Major
Found in lib/assets/js/simplePagination.js and 1 other location - About 1 hr to fix
lib/assets/js/simplePagination.js on lines 101..107

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

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

        enable: function(){
            var o = this.data('pagination');
            o.disabled = false;
            this.data('pagination', o);
            methods._draw.call(this);
Severity: Major
Found in lib/assets/js/simplePagination.js and 1 other location - About 1 hr to fix
lib/assets/js/simplePagination.js on lines 93..99

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

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

        _draw: function() {
            var    o = this.data('pagination'),
                interval = methods._getInterval(o),
                i;

Severity: Minor
Found in lib/assets/js/simplePagination.js - About 1 hr to fix

    Function set_clusters_from_comments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_clusters_from_comments(conversation, comment_map, exclusive=True, author=None):
        """
        Create clusters and stereotypes from conversation.
    
        Usage:
    Severity: Minor
    Found in src/ej_clusters/factories.py - 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 mautic has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def mautic(request, board_slug, conversation_id, slug, oauth2_code=None):
        conversation = Conversation.objects.get(id=conversation_id)
        user_signature = SignatureFactory.get_user_signature(conversation.author)
        tool = user_signature.get_tool(_("Mautic"), conversation)
        tool.raise_error_if_not_active()
    Severity: Minor
    Found in src/ej_tools/views.py - 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

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

            children.focus(function() {
                $(this).parent().css("background-color", "#30BFD3")
                $(this).parent().css("color", "white")
            })
    Severity: Major
    Found in lib/js/legacy/file-input.ts and 1 other location - About 1 hr to fix
    lib/js/legacy/file-input.ts on lines 10..13

    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

            children.blur(function() {
                $(this).parent().css("background-color", "#A3D8DD")
                $(this).parent().css("color", "#052B47");
            })
    Severity: Major
    Found in lib/js/legacy/file-input.ts and 1 other location - About 1 hr to fix
    lib/js/legacy/file-input.ts on lines 16..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 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 cluster_votes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def cluster_votes(conversation, users):
        clusterization = conversation.get_clusterization()
        comments = list(conversation.comments.all())
        comments_map = {comment.id: comment for comment in comments}
        clusters = {cluster: [] for cluster in clusterization.clusters.all()}
    Severity: Minor
    Found in src/ej_clusters/factories.py - 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 _stereotypes_votes_table has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _stereotypes_votes_table(self, mean, kind_col, cluster_col, **kwargs):
            # Prepare stereotype votes
            if mean:
                stereotype_votes = self.mean_stereotypes_votes_table()
            else:
    Severity: Minor
    Found in src/ej_clusters/models/cluster_queryset.py - 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 update_clusterization has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_clusterization(self, force=False, atomic=False):
            """
            Update clusters if necessary, unless force=True, in which it
            unconditionally updates the clusterization.
            """
    Severity: Minor
    Found in src/ej_clusters/models/clusterization.py - 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 make_lazy_importer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_lazy_importer(names):
        import demandimport
    
        slow_modules = set(names)
        sys_import = builtin_import
    Severity: Minor
    Found in src/ej/fixes/startup_accelerator.py - 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 watch_path has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def watch_path(path, func, poll_time=0.5, name=None, skip_first=False):
        """
        Watch path and execute the given function everytime a file changes.
        """
        import time
    Severity: Minor
    Found in etc/tasklib/base.py - 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 statistics_summary_dataframe has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def statistics_summary_dataframe(
            self,
            normalization=1,
            votes=None,
            comments=None,
    Severity: Minor
    Found in src/ej_conversations/mixins.py - 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 prepare_dataframe has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def prepare_dataframe(df, id="stats-table", pc=False):
        """
        Renders dataframe in a HTML table.
        """
        if pc is True:
    Severity: Minor
    Found in src/ej_dataviz/roles.py - 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 registerAllRoutes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function registerAllRoutes(workbox) {
        log('[sw] Starting service worker');
    
        // Cache javascript
        workbox.routing.registerRoute(
    Severity: Minor
    Found in src/ej/templates/jinja2/js/sw.js - About 1 hr to fix

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

      function enableFadeBottomDiv() {
          $(document).ready(function () {
              var lastScrollTop = 0;
              function hideLowerNav(windowWidth) {
                  if (windowWidth <= 550) {
      Severity: Minor
      Found in lib/js/legacy/utils.ts - About 1 hr to fix

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

        function registerElementForComponent(component, elem) {
            let $elem = $(elem),
                name = $elem.attr('is-element'),
                parts = name.split(':'),
                event = 'click',
        Severity: Minor
        Found in lib/js/components/base.ts - About 1 hr to fix

          Function init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  init: function(options) {
                      var o = $.extend({
                          items: 1,
                          itemsOnPage: 1,
                          pages: 0,
          Severity: Minor
          Found in lib/assets/js/simplePagination.js - About 1 hr to fix

            Function create_conversation has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def create_conversation(
            Severity: Major
            Found in src/ej_conversations/__init__.py - About 1 hr to fix

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

                      _appendItem: function(pageIndex, opts) {
                          var self = this, options, $link, o = self.data('pagination'), $linkWrapper = $('<li></li>'), $ul = self.find('ul');
              
                          pageIndex = pageIndex < 0 ? 0 : (pageIndex < o.pages ? pageIndex : o.pages - 1);
              
              
              Severity: Minor
              Found in lib/assets/js/simplePagination.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language