govau/performance-dashboard

View on GitHub

Showing 107 of 240 total issues

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

const DashboardWidgetDatagroupTimeSeriesPage = props => {
  const { slice } = props;
  const { widget, dashboard } = slice;

  let metadata = {

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 check_values_numericality has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def check_values_numericality
    if values.present?
      values.each do |k, v|
        if v.present? 
          unless v.is_a? Numeric
Severity: Minor
Found in app/models/data_row.rb - 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

Method slices has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def slices(widget, limit: 0)
    arr = []
    period_start = series_end&.beginning_of_month

    
Severity: Minor
Found in app/models/data_table.rb - 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 Field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const Field = props => {
  const {
    id,
    classNames,
    label,

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 check_frequency has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def check_frequency
    if data_table&.period.present?
      case data_table.period
      when 'month'
        query = data_table.data_rows.within_interval(
Severity: Minor
Found in app/models/data_row.rb - 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 convertData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function convertData(data) {
  if (!data || !data.length) {
    return null;
  } else {
    let tempData = data.map((c, i) =>
Severity: Minor
Found in client/src/_dashboard-legacy/Helpers/convertData.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

Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(widget, period, period_start, period_end, groups, data_rows=nil, row_label=nil)
Severity: Major
Found in app/models/slice.rb - About 50 mins to fix

    Function convertDataForLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function convertDataForLine(_data, _range) {
      let data = _data;
      let range = _range || 13;
      if (data && data.length) {
        for (let i = 0; i < data.length; i++) {
    Severity: Minor
    Found in client/src/_dashboard-legacy/Helpers/convertDataForLine.js - About 45 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 slices has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def slices(widget, limit: 0)
        puts 'RUNNING SLICES METHOD IN DATA TABLE DECORATOR ++++++++++++++++++++++++++++++++++'
    
        # Jon todo: this needs to differentiate between custom and month slices, same as the data table class function
        # For custom rows which will probably have the same month date, return a new slice with one row for each
    Severity: Minor
    Found in app/decorators/data_table_decorator.rb - About 45 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def update(options={}, &block)
          if params.dig(:widget, :options).present?
            begin
              resource.options = JSON.parse params[:widget].delete(:options)
            rescue JSON::ParserError => e
    Severity: Minor
    Found in app/admin/widget.rb - About 45 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 hasNegativeValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const hasNegativeValue = function hasNegativeValue(series) {
      let hasNegative = false;
      for (let i = 0; i < series.length; i++) {
        for (let j = 0; j < series[i].length; j++) {
          if (series[i][j].y < 0) {

    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 parse_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_values
          if params.dig(:data_row, :values).present?
            begin
              return JSON.parse params[:data_row].delete :values
            rescue JSON::ParserError => e
    Severity: Minor
    Found in app/admin/data_row.rb - About 45 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 create_full has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_full
        dashboard = Dashboard.new dashboard_params
        dashboard.notes = params[:notes].as_json
        dashboard.published_at = Time.now
        dashboard.save!
    Severity: Minor
    Found in app/controllers/api/v1/dashboards_controller.rb - About 45 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 create_kpis has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_kpis
        data_table = DataTable.create({
          :dashboard_id => @dashboard.id,
          :options => {
            :period => 'month',
    Severity: Minor
    Found in app/controllers/api/v1/widgets_controller.rb - About 45 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 handleGaEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      eventCategory,
      eventAction,
      eventLabel,
      eventValue,
      fieldsObject,
    Severity: Minor
    Found in client/src/_dashboard-legacy/services/google-analytics.js - About 35 mins to fix

      Function formatData has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      const formatData = function(value, _prefix, _suffix, rounded, isMoney) {

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

        const TrafficLight = ({
          dateSeriesEnd,
          datePublished,
          type,
          units,
        Severity: Minor
        Found in client/src/editor/scripts/components/widgetTrafficLight.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 summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def summary    
            num_rows = data_table&.data_rows&.count || 0
            
            if num_rows > 1 && datasets.count == 1 # Only for sparklines
              date = data_table.previous.row_date.to_formatted_s :month_year
        Severity: Minor
        Found in app/decorators/widget_decorator.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

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

        const requirablePropType = testFn => {
          function testProperty(props, propName, componentName) {
            var propVal = props[propName];
            var propIsEmpty = [undefined, null, ''].indexOf(propVal) > -1;
            //extract very last argument to see if this is required
        Severity: Minor
        Found in client/src/editor/scripts/utils/requirablePropType.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def update(options={}, &block)
              if params.dig(:dashboard, :notes).present?
                begin
                  resource.notes = JSON.parse params[:dashboard].delete(:notes)
                rescue JSON::ParserError => e
        Severity: Minor
        Found in app/admin/dashboard.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

        Severity
        Category
        Status
        Source
        Language