openaustralia/planningalerts

View on GitHub

Showing 12 of 56 total issues

Function barGraph has 160 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function barGraph(selector, url, metric) {

  // Add the title
  var wrapper_element = document.querySelectorAll(selector)[0];

Severity: Major
Found in app/assets/javascripts/bar_graph.js - About 6 hrs to fix

    Function barGraph has 154 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function barGraph(selector, url, metric) {
      // Add the chart
      d3.json(url, function(data) {
    
        data = data.map(function(d, i) {
    Severity: Major
    Found in app/assets/javascripts/tailwind/bar_graph.js - About 6 hrs to fix

      Class Tailwind has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Tailwind < ActionView::Helpers::FormBuilder
          extend T::Sig
      
          sig { params(method: Symbol, text: T.any(T.nilable(String), T::Hash[Symbol, String]), options: T::Hash[Symbol, String]).returns(String) }
          def label(method, text = nil, options = {})
      Severity: Minor
      Found in app/lib/form_builders/tailwind.rb - About 2 hrs to fix

        Method initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(tag:, size: nil, color: nil, font: nil, weight: nil, extra_classes: "")
              super
        
              default_size = DEFAULT_SIZES[tag]
              raise "Unexpected tag #{tag}" if default_size.nil?
        Severity: Minor
        Found in app/components/tailwind/heading.rb - 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

        Method initialize has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(size:, alignment:)
              super
        
              # Doing it this way so that tailwind doesn't compile the classes out
              case size
        Severity: Minor
        Found in app/components/tailwind/speech_bubble_component.rb - About 1 hr to fix

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

          async function initialiseGeocodingMap(map_div) {
            const { Map, InfoWindow } = await google.maps.importLibrary('maps');
            const { Marker } = await google.maps.importLibrary("marker");
          
            var g = JSON.parse(map_div.dataset.google);
          Severity: Minor
          Found in app/assets/javascripts/tailwind/maps.js - About 1 hr to fix

            Method attribute_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def attribute_value(value)
                if value.is_a?(Array)
                  safe_join(value.map { |v| attribute_value(v) })
                elsif value.class.respond_to?(:attribute_names)
                  render partial: "attribute_table", locals: { model: value }
            Severity: Minor
            Found in app/helpers/atdis_helper.rb - 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 initialiseAllMaps has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function initialiseAllMaps() {
              // Map on the application page
              var map_div = document.querySelector("#map_div.application");
              if (map_div) initialiseBasicMapWithMarker(map_div);
            
            
            Severity: Minor
            Found in app/assets/javascripts/maps.js - About 1 hr to fix

              Function initialiseGeocodingMap has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function initialiseGeocodingMap(map_div) {
                var googleLatLng = {lat: Number(map_div.dataset.googleLat), lng: Number(map_div.dataset.googleLng)};
                var mappifyLatLng = {lat: Number(map_div.dataset.mappifyLat), lng: Number(map_div.dataset.mappifyLng)};
              
                var map = new google.maps.Map(map_div, { zoom: 13, center: googleLatLng });
              Severity: Minor
              Found in app/assets/javascripts/maps/geocoding_map.js - About 1 hr to fix

                Function getAddress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                async function getAddress() {
                  try {
                    var pos = await getPosition({enableHighAccuracy: true, timeout: 10000});
                  } catch(err) {
                    if (err.code == 1) { // User said no
                Severity: Minor
                Found in app/assets/javascripts/geolocation.js - About 35 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

                Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def initialize(size:, alignment:)
                      super
                
                      # Doing it this way so that tailwind doesn't compile the classes out
                      case size
                Severity: Minor
                Found in app/components/tailwind/speech_bubble_component.rb - About 35 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

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

                  def changed_data_attributes
                    v = previous_version
                    if v
                      changed = {}
                      data_attributes.each_key do |a|
                Severity: Minor
                Found in app/models/application_version.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

                Severity
                Category
                Status
                Source
                Language