Sample

Schnappinger/diarymanagement/TBA.Logging.TBALogger

Human rating uses the original dataset scale.

Human2
Lines116

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
65.9Δ 61.6
Scalabrino0.8820–1; higher is more readable
84.2Δ 80.0
Dorn0.4720–1; higher is more readable
59.1Δ 54.8
Mi0.8180–1; higher is more readable
97.7Δ 93.4
LLOC24Logical lines; fewer is more readable
54.3Δ 50.0
DeepSeek V4 Pro100–20; mean of three runs
9.6Δ 5.3
GPT-6.1 Sol140–20; mean of three runs
16.2Δ 11.9
BTTF0.7640–1; higher is more readable
92.1Δ 87.8
Human21–4; original rating
4.3

Views

Source code

package TBA.Logging; import java.io.IOException; import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; import java.util.logging.ConsoleHandler; import java.util.logging.Handler; /** * This class initialises the parent logger *<p> * If any loggers have been instantiated before the settings have * been set by this class, you must manually apply the settings to * those loggers as well. * <p> * Any loggers created after calling this class, will inherit the * settings you set here. * <p> * @author Dan McGrath * * @version $Rev:: 96 $ $Date:: 2009-09-06 #$ * * @see java.util.logging.Logger */ public class TBALogger { /** * This constructor initialises the parent logger specifying the log filename *<p> * @param logfile Filename to write log entries to * @throws IOException * * @see #setup() */ static public void setup(String logfile) throws IOException { FileHandler fileTxt; // Get the parent Logger and set default values Logger logger = Logger.getLogger(""); logger.setLevel(Level.INFO); if(logfile.compareTo("") == 0 || logfile != null) { // Setup the logger to write to the filename passed in. fileTxt = new FileHandler(logfile); fileTxt.setFormatter(new SimpleFormatter()); logger.addHandler(fileTxt); } } /** * This constructor initialises the parent logger. A default log filename of * TBALog is set *<p> * @throws IOException * * @see #setup(java.lang.String) */ static public void setup() throws IOException { FileHandler fileTxt; // Create Logger Logger logger = Logger.getLogger(""); logger.setLevel(Level.INFO); // Setup the logger to write to file. fileTxt = new FileHandler("TBALog"); fileTxt.setFormatter(new SimpleFormatter()); logger.addHandler(fileTxt); // Setup the logger to write to the console logger.addHandler(new ConsoleHandler()); } /** * This method sets the Level of detail to log of the parent logger and all * it's handlers *<p> * @param loglevel The level of detail to set the logger to. *<p> * @throws IOException *<p> * @see java.util.logging.Logger#setLevel(java.util.logging.Level) * @see java.util.logging.Handler#setLevel(java.util.logging.Level) */ static public void setLevel(Level loglevel) throws IOException { // Create Logger Logger logger = Logger.getLogger(""); logger.setLevel(loglevel); // Setup the logger to write to the console for(Handler logHandler : logger.getHandlers()) { logHandler.setLevel(loglevel); } } /** * This method removes the first handler from the parent log. The first time * you call this it should be the ConsoleHandler *<p> * @see java.util.logging.ConsoleHandler * @see java.util.logging.Logger#removeHandler(java.util.logging.Handler) */ static public void removeConsole() { Logger logger = Logger.getLogger(""); logger.removeHandler(logger.getHandlers()[0]); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.1720.703−56.783
Source linesThe number of non-empty source lines.116+46.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.694−7.041

Intercept 8.87 + feature contributions = -8.554 (log-odds).
Score = sigmoid(-8.554) = 0.

Score0.882

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.115−3.035
Indentation frequencyHow rapidly indentation changes from line to line.64+1.477
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.114.815+1.195
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.64−1.048
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.048+0.476
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.79.233+0.474
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.79.948+0.279

Intercept 0.07 + feature contributions = -0.113 (log-odds).
Score = sigmoid(-0.113) = 0.472.

Score0.818
Score24
Run 1

The code has inconsistent indentation, mixed tabs and spaces, and Javadoc comments that inaccurately describe constructors when the methods are static. Logical errors exist, such as the condition `logfile.compareTo("") == 0 || logfile != null`, which can cause a NullPointerException. The `removeConsole()` method removes the first handler without checking if it is actually the console handler, and ignores handler count. The class structure is generally flat, but the methods are not entirely cohesive; `setup()` overloads duplicate logic. Import statements include unused entries. Overall, the intent is understandable for a simple logging utility, but these issues make the code confusing and unsafe.

Run 2

The code has clear intent and is logically organized with separated methods, but suffers from several readability issues. The boolean condition `if(logfile.compareTo("") == 0 || logfile != null)` is ambiguous and likely incorrect, undermining clarity. Inconsistent indentation with mixed tabs/spaces disrupts reading flow. There is dead or unused imported classes. Javadoc comments are verbose and often poorly worded, adding length without improving understanding. Variable naming like `fileTxt` is not descriptive, and actions are combined in some lines. Nesting is minimal, which is good, but the overall structure could be more concise. Error handling and redundant logger creation further reduce clarity.

Run 3

The code is generally organized with clear method separation and Javadoc comments, but suffers from several readability issues. The conditional `if(logfile.compareTo("") == 0 || logfile != null)` is logically inverted and confusing - it suggests the file handler is created when the string is empty or not null, which is essentially always true but contradicts the apparent intent. Variable declarations like `fileTxt` are unnecessarily pre-declared, and mixing tabs and spaces creates inconsistent indentation. The class Javadoc and method comments are verbose relative to the simple logic. The `removeConsole()` method assumes index 0 is ConsoleHandler, which is fragile and unclear without a guard check. There's also no consistency between the two `setup()` overloads in how they apply handlers. While each method performs one logical action, the flow is somewhat disjointed, and unused imports like `Handler` and `ConsoleHandler` are declared but not properly utilized. The overall action granularity is acceptable, but the nesting and clarity of intent need improvement.

Run 1

Code Structure: Small, logically separated methods organize logger setup and configuration, although setup logic is duplicated. Nesting: Shallow conditionals and a single loop make control flow easy to follow. Clarity of intent: Method names mostly communicate purpose, but documentation incorrectly calls methods constructors, some comments are misleading, and removeConsole assumes the first handler is the console handler. The logfile condition is confusing: it dereferences before checking null and accepts every non-null string. Code length: Implementation is reasonably concise, but repetitive Javadoc and duplicated setup steps add unnecessary length. Action granularity: Each statement performs one clear action, aiding readability. Reading flow: Operations follow a natural sequence, but inconsistent indentation, mixed tabs and spaces, and uneven formatting interrupt scanning.

Run 2

Code Structure: Small, logically separated methods organize logger setup, level changes, and handler removal, though setup logic is duplicated. Nesting: Shallow conditionals and a single loop make control flow easy to follow. Clarity of intent: Method names and documentation communicate the overall purpose, but comments incorrectly call methods constructors, removeConsole assumes the first handler is the console handler, and the logfile condition is confusing and null-unsafe. Code length: Implementation is reasonably concise, but repetitive setup and verbose documentation add unnecessary length. Action granularity: Statements generally perform one action per line, supporting readability. Reading flow: Method ordering is natural, but inconsistent indentation, mixed tabs and spaces, outdated metadata, and misleading comments interrupt the flow.

Run 3

Code Structure: Small, focused methods provide logical organization, but the setup overloads duplicate initialization. Nesting: Shallow conditionals and a single loop make control flow easy to follow. Clarity of intent: Method names and logging API calls mostly communicate purpose, but the logfile condition is confusing and null-unsafe. Documentation incorrectly calls methods constructors, and removeConsole removes the first handler rather than explicitly identifying a console handler. Code length: Implementation is reasonably concise, though repetitive Javadoc, obvious comments, and duplicated setup code add noise. Action granularity: Statements generally perform one action per line. Reading flow: Method ordering is natural, but inconsistent indentation, mixed tabs and spaces, and misleading comments interrupt scanning.