Record Class MetricLimit.RatioLimit

java.lang.Object
java.lang.Record
org.ek9lang.compiler.support.MetricLimit.RatioLimit
Record Components:
metricKey - stable machine key
ruleCode - the EK9 error code this enforces
threshold - the fractional score above which it fires
All Implemented Interfaces:
MetricLimit
Enclosing interface:
MetricLimit

public static record MetricLimit.RatioLimit(String metricKey, String ruleCode, double threshold) extends Record implements MetricLimit
A gate on a fractional score rather than a count — E11020 multiplies a construct's complexity ratio by its statement ratio and fires above 0.50, so neither operand is a limit in its own right and the threshold cannot be an int.
  • Constructor Details

    • RatioLimit

      public RatioLimit(String metricKey, String ruleCode, double threshold)
      Creates an instance of a RatioLimit record class.
      Parameters:
      metricKey - the value for the metricKey record component
      ruleCode - the value for the ruleCode record component
      threshold - the value for the threshold record component
  • Method Details

    • comparison

      public MetricLimit.Comparison comparison()
      Always > — exposed as a method rather than a record component because, unlike the counted gates, a ratio has no reason to ever be inclusive.
    • isOver

      public boolean isOver(double value)
      The exact predicate the checker uses to fire.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • metricKey

      public String metricKey()
      Returns the value of the metricKey record component.
      Specified by:
      metricKey in interface MetricLimit
      Returns:
      the value of the metricKey record component
    • ruleCode

      public String ruleCode()
      Returns the value of the ruleCode record component.
      Specified by:
      ruleCode in interface MetricLimit
      Returns:
      the value of the ruleCode record component
    • threshold

      public double threshold()
      Returns the value of the threshold record component.
      Returns:
      the value of the threshold record component