Record Class FileMetrics
java.lang.Object
java.lang.Record
org.ek9lang.compiler.ir.data.FileMetrics
- Record Components:
readabilityScore- Human-readable grade (e.g., "10-11 Fifth Grade")readabilityLevel- Numeric level (1-12+, lower is better)totalLines- Total lines in filecodeLines- Lines containing codecommentLines- Lines containing commentsavgFunctionComplexity- Average cyclomatic complexity of functions in filemaxFunctionComplexity- Maximum cyclomatic complexity in file
public record FileMetrics(String readabilityScore, int readabilityLevel, int totalLines, int codeLines, int commentLines, double avgFunctionComplexity, int maxFunctionComplexity)
extends Record
File-level metrics including ARI readability.
Associated with CompilableSource for per-file analysis. The ARI (Automated Readability Index) readability metric is UNIQUE to EK9 - no competitor offers source code readability analysis.
ARI has been adapted for source code by considering:
- Identifier length (long names increase complexity)
- Expression density (many operators reduce readability)
- Indentation patterns (structure affects understanding)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FileMetricsEmpty metrics for files without collected data. -
Constructor Summary
ConstructorsConstructorDescriptionFileMetrics(String readabilityScore, int readabilityLevel, int totalLines, int codeLines, int commentLines, double avgFunctionComplexity, int maxFunctionComplexity) Creates an instance of aFileMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theavgFunctionComplexityrecord component.intReturns the value of thecodeLinesrecord component.intReturns the value of thecommentLinesrecord component.doubleGet comment ratio (0.0 to 1.0).final booleanIndicates whether some other object is "equal to" this one.booleanhasData()Check if this record has any meaningful data.final inthashCode()Returns a hash code value for this object.booleanCheck if file has high average complexity.booleanCheck if readability needs improvement.booleanCheck if file has very complex functions.intReturns the value of themaxFunctionComplexityrecord component.booleanCheck if this file needs attention based on any metric.CSS class for readability status indicator.Readability interpretation for display.intReturns the value of thereadabilityLevelrecord component.Returns the value of thereadabilityScorerecord component.toString()Returns a string representation of this record class.intReturns the value of thetotalLinesrecord component.
-
Field Details
-
EMPTY
Empty metrics for files without collected data.
-
-
Constructor Details
-
FileMetrics
public FileMetrics(String readabilityScore, int readabilityLevel, int totalLines, int codeLines, int commentLines, double avgFunctionComplexity, int maxFunctionComplexity) Creates an instance of aFileMetricsrecord class.- Parameters:
readabilityScore- the value for thereadabilityScorerecord componentreadabilityLevel- the value for thereadabilityLevelrecord componenttotalLines- the value for thetotalLinesrecord componentcodeLines- the value for thecodeLinesrecord componentcommentLines- the value for thecommentLinesrecord componentavgFunctionComplexity- the value for theavgFunctionComplexityrecord componentmaxFunctionComplexity- the value for themaxFunctionComplexityrecord component
-
-
Method Details
-
hasReadabilityIssue
public boolean hasReadabilityIssue()Check if readability needs improvement.Level > 10 (11th grade reading level or above) indicates code that may be too complex for easy understanding.
- Returns:
- true if readability level exceeds threshold
-
commentRatio
public double commentRatio()Get comment ratio (0.0 to 1.0).A ratio of 0.1-0.3 is typically healthy. Very low may indicate under-documented code. Very high may indicate code that's hard to understand without comments.
- Returns:
- ratio of comment lines to code lines
-
readabilityInterpretation
Readability interpretation for display.- Returns:
- human-readable assessment of readability
-
hasHighAverageComplexity
public boolean hasHighAverageComplexity()Check if file has high average complexity.- Returns:
- true if average function complexity > 10
-
hasVeryComplexFunctions
public boolean hasVeryComplexFunctions()Check if file has very complex functions.- Returns:
- true if max function complexity > 20
-
needsAttention
public boolean needsAttention()Check if this file needs attention based on any metric.- Returns:
- true if any metric indicates a problem
-
hasData
public boolean hasData()Check if this record has any meaningful data.- Returns:
- true if any metric has data
-
readabilityCssClass
CSS class for readability status indicator.- Returns:
- CSS class name for styling
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
readabilityScore
Returns the value of thereadabilityScorerecord component.- Returns:
- the value of the
readabilityScorerecord component
-
readabilityLevel
public int readabilityLevel()Returns the value of thereadabilityLevelrecord component.- Returns:
- the value of the
readabilityLevelrecord component
-
totalLines
public int totalLines()Returns the value of thetotalLinesrecord component.- Returns:
- the value of the
totalLinesrecord component
-
codeLines
-
commentLines
public int commentLines()Returns the value of thecommentLinesrecord component.- Returns:
- the value of the
commentLinesrecord component
-
avgFunctionComplexity
public double avgFunctionComplexity()Returns the value of theavgFunctionComplexityrecord component.- Returns:
- the value of the
avgFunctionComplexityrecord component
-
maxFunctionComplexity
public int maxFunctionComplexity()Returns the value of themaxFunctionComplexityrecord component.- Returns:
- the value of the
maxFunctionComplexityrecord component
-