Sample

Schnappinger/aoi/artofillusion.spmanager.SPManagerUtils

Human rating uses the original dataset scale.

Human2.01
Lines412

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
17.7Δ 12.4
Scalabrino0.7970–1; higher is more readable
61.6Δ 56.4
Dorn0.0110–1; higher is more readable
20.5Δ 15.2
Mi0.3410–1; higher is more readable
21.1Δ 15.8
LLOC178Logical lines; fewer is more readable
15.3Δ 10.1
DeepSeek V4 Pro9.330–20; mean of three runs
7.8Δ 2.5
GPT-6.1 Sol110–20; mean of three runs
3.3Δ 2.0
BTTF0.3520–1; higher is more readable
27.7Δ 22.4
Human2.011–4; original rating
5.3

Views

Source code

/* * This class implements utilities */ /* * Copyright (C) 2003 by Francois Guillet * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package artofillusion.spmanager; import java.awt.*; import javax.swing.*; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.*; import java.io.*; import java.util.zip.*; import artofillusion.*; import artofillusion.ui.*; /** * Description of the Class * *@author pims *@created 6 juillet 2004 */ public class SPManagerUtils { public static DocumentBuilderFactory factory; public static DocumentBuilder builder; static { factory = DocumentBuilderFactory.newInstance(); try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException ex) { ex.printStackTrace(); } } /** * Description of the Method * *@param intArray Description of the Parameter *@return Description of the Return Value */ public static int[] increaseIntArray( int[] intArray ) { if ( intArray == null ) { int[] tmpArray = new int[1]; return tmpArray; } else { int[] tmpArray = new int[intArray.length + 1]; System.arraycopy( intArray, 0, tmpArray, 0, intArray.length ); return tmpArray; } } /** * Description of the Method * *@param intArray Description of the Parameter *@param element Description of the Parameter *@return Description of the Return Value */ public static int[] deleteIntArrayElement( int[] intArray, int element ) { if ( intArray == null ) return null; else if ( intArray.length == 1 ) return null; else { int[] tmpArray = new int[intArray.length - 1]; if ( element > 0 ) System.arraycopy( intArray, 0, tmpArray, 0, element ); if ( element < intArray.length - 1 ) System.arraycopy( intArray, element + 1, tmpArray, element, tmpArray.length - element ); int i; return tmpArray; } } /** * Sets the dialogLocation attribute of the SPManagerUtils class * *@param frame The new dialogLocation value *@param parentFrame The new dialogLocation value */ public static void setDialogLocation( JFrame frame, JFrame parentFrame ) { Point location = new Point(); location.x = parentFrame.getLocation().x + parentFrame.getWidth() / 2 - frame.getWidth() / 2; location.y = parentFrame.getLocation().y + parentFrame.getHeight() / 2 - frame.getHeight() / 2; if ( location.x < 0 ) location.x = 0; if ( location.y < 0 ) location.y = 0; frame.setLocation( location ); } /** * Description of the Method */ public static void updateAllAoIWindows() { try { EditingWindow allWindows[] = ArtOfIllusion.getWindows(); for ( int i = 0; i < allWindows.length; i++ ) if ( allWindows[i] instanceof LayoutWindow ) ( (LayoutWindow) allWindows[i] ).rebuildScriptsMenu(); } catch (Throwable t) {} } /** * Gets the jarFileContent attribute of the SPManagerUtils class * *@param filename Description of the Parameter *@return The jarFileContent value */ public static byte[] getJarFileContent( String filename ) { File dir = new File( SPManagerPlugin.PLUGIN_DIRECTORY ); if ( dir.exists() ) { String[] files = dir.list(); for ( int i = 0; i < files.length; i++ ) if ( files[i].startsWith( "SPManager" ) ) { ZipFile zf = null; try { zf = new ZipFile( new File( dir, files[i] ) ); } catch ( IOException ex ) { continue; // Not a zip file. } if ( zf != null ) { ZipEntry ze = zf.getEntry( filename ); if ( ze != null ) { int size = (int) ze.getSize(); byte data[] = new byte[size]; try { BufferedInputStream in = new BufferedInputStream( zf.getInputStream( ze ) ); for ( int j = 0; j < size; j++ ) data[j] = (byte) in.read(); in.close(); } catch ( IOException ex ) { System.out.println( "IOException in getJarFileContent" ); } return data; } else System.out.println( "File " + filename + " not found within zip file" ); } } } else { System.out.println( "Dir does not exist" ); } return null; } /** * Gets the jarFileContent attribute of the SPManagerUtils class * *@param jarPath Description of the Parameter *@param filename Description of the Parameter *@return The jarFileContent value */ public static byte[] getJarFileContent( String jarPath, String filename ) { ZipFile zf = null; try { zf = new ZipFile( new File( jarPath ) ); } catch ( IOException ex ) { return null; // Not a zip file. } if ( zf != null ) { ZipEntry ze = zf.getEntry( filename ); if ( ze != null ) { int size = (int) ze.getSize(); byte data[] = new byte[size]; try { BufferedInputStream in = new BufferedInputStream( zf.getInputStream( ze ) ); for ( int j = 0; j < size; j++ ) data[j] = (byte) in.read(); in.close(); } catch ( IOException ex ) { System.out.println( "IOException in getJarFileContent" ); } return data; } else System.out.println( "File " + filename + " not found within zip file" ); } return null; } /** * Gets a named node from a node list. Returns null if the node does not * exist. * *@param nl The node list *@param nodeName The node name *@return The node named nodeName */ public static Node getNodeFromNodeList( NodeList nl, String nodeName, int index ) { for ( int i = 0; i < nl.getLength(); ++i ) { Node n = nl.item( i ); if ( n.getNodeName().equals( nodeName ) ) { if (index-- == 0) return n; } } return null; } /** * Gets a named attribute value from a node * *@param name The attribute name *@param node Description of the Parameter *@return The attribute value */ public static String getAttribute( Node node, String name ) { NamedNodeMap nm = node.getAttributes(); if ( nm == null ) return null; Node nn = nm.getNamedItem( name ); if ( nn == null ) return null; return nn.getNodeValue(); } /** * Gets a value from a named child node * *@param name The child node name *@param node The node *@return The attribute value */ public static String getNodeValue( Node node, String name, String defaultVal, int index) { NodeList nl = node.getChildNodes(); if ( nl.getLength() == 0 ) return defaultVal; Node n = getNodeFromNodeList( nl, name, index ); if ( n == null ) return defaultVal; n = n.getChildNodes().item(0); if (n == null) return defaultVal; String value = n.getNodeValue(); if (value == null) value = defaultVal; return value; } /** * method to parse digits into an int */ public static int parseInt(String val, int start, int max) throws NumberFormatException { if (val == null || val.length() <= start) return 0; if (max < 0 || max > val.length()) max = val.length(); char c; // throw exception if the value cannot be a number c = val.charAt(start); if (! (Character.isDigit(c) || "+-".indexOf(c) >= 0)) throw new NumberFormatException(val); int result = 0; for (int i = start; i < max; i++) { c = val.charAt(i); if (Character.isDigit(c)) result = (result*10) + Character.digit(c, 10); else break; } return result; } /** * parse a double value from a String. * * The string is parsed from the first (zeroeth) char up to the first * char which is not valid in a double representation * (ie digit, '.', 'e', 'E', '+', or '-'). */ public static double parseDouble(String val) throws NumberFormatException { if (val == null || val.length() == 0) return 0; char c; // throw exception if the value cannot be a number c = val.charAt(0); if (! (Character.isDigit(c) || "+-.".indexOf(c) >= 0)) throw new NumberFormatException(val); long result = 0; long frac = 0; int exp = 0; boolean mantissa = true; int sign = 1, esign = 1; int max = val.length(); for (int i = 0; i < max; i++) { c = val.charAt(i); if (result == 0 && (c == '-' || c == '+')) sign = (c == '-' ? -1 : 1); else if (frac == 0 && c == '.') frac = 1; else if (mantissa == true && (c == 'e' || c == 'E')) mantissa = false; else if (Character.isDigit(c)) { if (mantissa) { result = (result*10) + Character.digit(c, 10); if (frac > 0) frac *= 10; System.out.println("test: c=" + c + "; frac=" + frac); } else { if (exp == 0 && (c == '-' || c == '+')) esign = (c == '-' ? -1 : 1); else exp = (exp*10) + Character.digit(c, 10); } } else break; } if (frac == 0) frac = 1; System.out.println("parseDouble: esign:" + esign + "; exp:" + exp + "; sign:" + sign + "; result:" + result + "; frac:" + frac); return (Math.pow(10.0, esign * exp) * sign * result)/frac; } /** * parse a version string into a numeric value. * * Each component is parsed as an int and scaled into a 3-digit * column. *<br>Eg 1.2 is parsed into 1002; 1.20 is parsed into 1020; and 1.20.3 * is parsed into 1020003 * */ public static long parseVersion(String val) throws NumberFormatException { long result = parseInt(val, 0, -1); int pos = 0; while ((pos = val.indexOf('.', pos)) >= 0) { result = (result*1000) + parseInt(val, pos+1, -1); pos++; } return result; } }

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.13700.5−452.117
Source linesThe number of non-empty source lines.412+164.8
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.405−6.608

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

Score0.797

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.413−13.587
Indentation frequencyHow rapidly indentation changes from line to line.328+10.608
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.328−7.106
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.411.862+5.347
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.107.988+0.938
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.107.971−0.908
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.086+0.108

Intercept 0.07 + feature contributions = -4.529 (log-odds).
Score = sigmoid(-4.529) = 0.011.

Score0.341
Score178
Run 1

The code has some structural organization with methods separated by comments, but suffers from multiple readability issues. Public mutable static fields (factory, builder) are a code smell. Methods like getJarFileContent have deep nesting (5+ levels) and duplicated logic. There are leftover debug System.out.println statements, commented-out code, and meaningless variable names (c, n, nl). Inconsistent indentation (tabs vs spaces) and brace styles reduce readability. The parseDouble method has confusing logic with poor naming (frac as multiplier), redundant comments, and a stray debug print inside a loop. Method signatures like getNodeFromNodeList with unaligned parameters are awkward. The empty catch block (Throwable t) hides errors. Overall, the code lacks clean separation of concerns and has unclear intent in several places, making maintenance difficult.

Run 2

The code is moderately readable but has several issues. Structure is logical with utility methods, but many are overly long (getJarFileContent has deep nesting and repeated logic). Nesting reaches 4-5 levels in file/zip handling, hurting comprehension. Intent is often unclear due to placeholder comments like 'Description of the Method' and vague parameter names. Code length is excessive - the two getJarFileContent overloads duplicate significant logic. Action granularity is inconsistent: some lines combine multiple operations while others are appropriately granular. Reading flow is disrupted by debug System.out.println statements left in parseDouble, unused variables (int i in deleteIntArrayElement), and inconsistent indentation (mixed tabs/spaces). Some methods like parseInt/parseDouble have complex logic without sufficient comments explaining edge cases. Static mutable fields (factory, builder) lack encapsulation. Positive aspects include separate concerns, reasonable method decomposition, and Javadoc presence, though content is often unhelpful.

Run 3

The code has a basic logical structure with related methods grouped in a utility class, but several factors reduce readability. Nesting is moderate to deep, especially in getJarFileContent and parseDouble. Javadocs are present but mostly useless placeholders ('Description of the Method'), while some non-obvious methods lack meaningful comments. Length is verbose for simple array operations. Action granularity is mixed—setDialogLocation is clear one-action-per-line, but parseDouble crams multiple operations into dense loops. Reading flow is disrupted by inconsistent brace style (K&R vs Allman), inconsistent indentation (tabs/spaces), and debug System.out.println calls left in code. The class-level static mutable fields factory/builder are also a design concern. The intent is generally discernible, but the inconsistent formatting and dead code significantly impede readability.

Run 1

Code Structure: Separate utility methods provide reasonable organization, but unrelated responsibilities share one class and ZIP-reading logic is duplicated. Nesting: Simple helpers are shallow, while archive lookup and double parsing contain deeply nested branches. Clarity of intent: Most method names convey purpose, but placeholder documentation, abbreviated variables, opaque parser state, and silent exception handling obscure details. Code length: Several helpers are concise; redundant branches, boilerplate comments, duplicated implementations, and debug output add unnecessary length. Action granularity: Most statements occupy separate lines, but inline conditionals, combined declarations, and decrementing an index within a condition compress distinct actions. Reading flow: Method boundaries help navigation, but inconsistent indentation, brace usage, spacing, and parameter alignment interrupt scanning. Overall, the code is understandable with effort, with archive extraction and numeric parsing notably harder to follow.

Run 2

Code Structure: Separate utility methods provide reasonable organization, but unrelated responsibilities and duplicated ZIP-reading logic weaken cohesion. Nesting: Most helpers are shallow, while ZIP extraction and numeric parsing contain substantial nesting. Clarity of intent: Method names generally communicate purpose, but placeholder documentation, abbreviated variables, undocumented index semantics, and complex parser state obscure details. Code length: Several helpers are concise, but duplicated implementations, boilerplate comments, redundant branches, and an unused declaration add unnecessary length. Action granularity: Most statements perform one action per line; inline conditionals, combined declarations, and decrementing an index within a condition reduce clarity. Reading flow: Method boundaries are clear, but inconsistent indentation, brace placement, tabs, and parameter alignment interrupt scanning. Silent exception handling and leftover debug output also make execution flow harder to interpret.

Run 3

Code Structure: Separate utility methods provide reasonable organization, but unrelated responsibilities and duplicated ZIP-reading logic weaken cohesion. Nesting: Most helpers are shallow, while ZIP extraction and double parsing contain substantial nesting. Clarity of intent: Method names generally communicate purpose, but placeholder documentation, abbreviated variables, undocumented index semantics, and intricate parsing state obscure details. Code length: Several helpers are concise; redundant branches, repeated implementations, boilerplate comments, and debugging output add unnecessary length. Action granularity: Most statements perform one action per line, but inline conditionals, combined declarations, and decrementing an index inside a condition reduce clarity. Reading flow: Methods are individually approachable, but inconsistent indentation, brace styles, awkward parameter alignment, empty exception handling, and debug prints disrupt the overall flow.