codeforamerica/citygram

View on GitHub

Showing 11 of 11 total issues

Function hookupSteps has 121 lines of code (exceeds 25 allowed). Consider refactoring.
Open

app.hookupSteps = function() {
  $('.startButton').on('click', function() {
    app.scrollToElement($('#step1'));
  });

Severity: Major
Found in app/assets/js/scripts.js - About 4 hrs to fix

    File scripts.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    $(document).ready(function() {
      app.hookupMap();
      app.hookupSteps();
      app.hideSteps();
    });
    Severity: Minor
    Found in app/assets/js/scripts.js - About 3 hrs to fix

      Function geolocate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        app.geolocate = function(e) {
          e && e.preventDefault();
          var address = $('#geolocate').val();
          if (! address) { return }
          var city = undefined;
      Severity: Minor
      Found in app/assets/js/scripts.js - About 1 hr to fix

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

        app.hookupSteps = function() {
          $('.startButton').on('click', function() {
            app.scrollToElement($('#step1'));
          });
        
        
        Severity: Minor
        Found in app/assets/js/scripts.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 hookupMap has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        app.hookupMap = function() {
          document.getElementById('locatormap').innerHTML = "<div id='map'><div class='map-key-panel js-dot-legend'><span class='map-event-dot'></span>Click to see notification</div></div>";
          var center = JSON.parse($('meta[name=mapCenter]').attr('content'));
          var options = {
            zoom: 13,
        Severity: Minor
        Found in app/assets/js/scripts.js - About 1 hr to fix

          Function hookupMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          app.hookupMap = function() {
            document.getElementById('locatormap').innerHTML = "<div id='map'><div class='map-key-panel js-dot-legend'><span class='map-event-dot'></span>Click to see notification</div></div>";
            var center = JSON.parse($('meta[name=mapCenter]').attr('content'));
            var options = {
              zoom: 13,
          Severity: Minor
          Found in app/assets/js/scripts.js - About 55 mins 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 geocode has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          app.geocode = function(address, city, state, callback, context) {
          Severity: Minor
          Found in app/assets/js/scripts.js - About 35 mins to fix

            Method call has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def call(name, starts, ends, _, env)
            Severity: Minor
            Found in app/services/connection_builder.rb - About 35 mins to fix

              Method perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def perform(subscription_id)
                    subscription = Subscription.first!(id: subscription_id)
                    publisher = subscription.publisher
              
                    # TODO: get rid of this case statement
              Severity: Minor
              Found in app/workers/subscription_confirmation.rb - About 25 mins 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

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

                  rescue Twilio::REST::RequestError => e
                    Citygram::App.logger.error(e)
              
                    if Citygram::Services::Channels::SMS::UNSUBSCRIBE_ERROR_CODES.include?(e.code.to_i)
                      # unsubscribe and skip retries
              Severity: Minor
              Found in app/workers/subscription_confirmation.rb and 1 other location - About 25 mins to fix
              app/workers/reminder_notification.rb on lines 29..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 30.

              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

                  rescue Twilio::REST::RequestError => e
                    Citygram::App.logger.error(e)
              
                    if Citygram::Services::Channels::SMS::UNSUBSCRIBE_ERROR_CODES.include?(e.code.to_i)
                      # unsubscribe and skip retries
              Severity: Minor
              Found in app/workers/reminder_notification.rb and 1 other location - About 25 mins to fix
              app/workers/subscription_confirmation.rb on lines 32..41

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

              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