Class: PgCanary::Rules::Detection

Inherits:
Struct
  • Object
show all
Defined in:
lib/pg_canary/rules/detection.rb

Overview

What a rule's #check returns: one anti-pattern finding — which rule fired, on which query, which table/columns are involved, why it is a problem, and how to fix it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnsObject

Returns the value of attribute columns

Returns:

  • (Object)

    the current value of columns



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def columns
  @columns
end

#fingerprintObject

Returns the value of attribute fingerprint

Returns:

  • (Object)

    the current value of fingerprint



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def fingerprint
  @fingerprint
end

#locationObject

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def location
  @location
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def message
  @message
end

#rule_nameObject

Returns the value of attribute rule_name

Returns:

  • (Object)

    the current value of rule_name



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def rule_name
  @rule_name
end

#severityObject

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def severity
  @severity
end

#sqlObject

Returns the value of attribute sql

Returns:

  • (Object)

    the current value of sql



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def sql
  @sql
end

#suggestionObject

Returns the value of attribute suggestion

Returns:

  • (Object)

    the current value of suggestion



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def suggestion
  @suggestion
end

#tableObject

Returns the value of attribute table

Returns:

  • (Object)

    the current value of table



10
11
12
# File 'lib/pg_canary/rules/detection.rb', line 10

def table
  @table
end

Instance Method Details

#truncated_sqlObject



15
16
17
18
# File 'lib/pg_canary/rules/detection.rb', line 15

def truncated_sql
  squashed = sql.to_s.strip.gsub(/\s+/, " ")
  squashed.length > MAX_SQL_LENGTH ? "#{squashed[0, MAX_SQL_LENGTH]}" : squashed
end