input
stringlengths
10
828
output
stringlengths
5
107
public void set debug type string debug type this debug type debug type
class name to debug
public void set base line date base line this base line base line
date of baseline report
public void set embedded inspectors boolean embedded inspectors this embedded inspectors embedded inspectors
load embedded inspectors
public void add first inspector descriptor descriptor stack add first descriptor
adds descriptor at the beginning of the stack will be used first
public void report violation source marker source report violation source descriptor get message
reports violation with a message from descriptor
public void report violation ex source marker source string message key report violation source descriptor get message message key
reports violation with a message from descriptor
public void report violation source marker source object params string message descriptor get message if message null warn source message not found for inspector get descriptor get name message generic message report violation source message format format message params
formats message taken from inspector descriptor with parameters
public void report violation ex source marker source object params string message key string message descriptor get message message key if message null warn source message with key message key not found for inspector get descriptor get name message generic message report violation source message format format message for key message key params
formats message taken from inspector descriptor with parameters
public void info source marker source string message if logger null logger info this logger message source message
outputs a message to the log
public void debug source marker source string message if logger null logger debug this logger message source message
outputs a message to the log
public void verbose source marker source string message if logger null logger verbose this logger message source message
outputs a message to the log
public void set host id string host id this host id host id
host id to differentiate reports created on different machines
public void set calculate dependencies boolean calculate dependencies this calculate dependencies calculate dependencies
if set to true hammurapi stores dependency information to the
public void set store source boolean store source this store source store source
if set to true hammurapi stores source code to the database
public void add server server entry server this server server
database hypersonic server to use as repository
public void add connection connection entry connection this connection connection
defines database server to be used as repository
public history output create history output history output history output new history output outputs add history output return history output
defines history output which stores review summary
public path create classpath if class path null class path new path project return class path create path
maybe creates a nested classpath element
public void set embedded style boolean embedded style this embedded style embedded style
use embedded stylesheets if no stylesheets has been set explicitly
public void set java doc dir file java doc dir this java doc dir java doc dir
java doc directory to generate links
public waiver source entry create waivers waiver source entry ret new waiver source entry ret set project get project waivers add ret return ret
defines waivers source
public inspector source entry create inspectors inspector source entry ret new inspector source entry inspectors add ret ret set project get project return ret
defines inspector source
public void set archive file archive this archive archive
hammurapi archive to process
public void set dpmo threshold int dpmo threshold throws build exception this dpmo threshold new integer dpmo threshold
fail build if project dpmo is above the threshold
public filter entry create filter include filter entry fe new filter entry filter entries add fe return fe
inspector to include to filtering
public filter entry create filter exclude filter entry fe new filter entry filter entries add fe fe exclude true return fe
inspector to exclude from filtering
public void set sigma threshold double sigma threshold throws build exception this sigma threshold new double sigma threshold
fail build if project sigma is below the threshold
public void set force boolean force this force force boolean true boolean false
force review even if the file is not changed
public void set force on warnings boolean force on warnings this force on warnings force on warnings boolean true boolean false
force review of files with warnings even if the file is not changed
public file set create src file set ret new hammurapi file set java src file sets add ret return ret
source files fileset
public void set fail on first exception boolean fail on first exception this fail on first exception fail on first exception
fail build as soon as there is an exception
public void set review description string review description this review description review description
description of review e
public void set fail on warnings boolean fail on warnings this fail on warnings fail on warnings
fail build if there have been warnings
public collection get parameters list ret new linked list iterator it super get parameters iterator while it has next param p param it next ret add new parameter entry p get name p get object null return ret
convert entries from param to parameter entry
public void set severity threshold int severity threshold this severity threshold new integer severity threshold
fail build on violations with severity levels lower or equal to the threshold
public void set waiver stubs file waiver stubs this waiver stubs waiver stubs
file to output waiver stubs for rejected waiver requests to
public void set evict bad inspectors boolean evict bad inspectors this evict bad inspectors evict bad inspectors
remove inspector from inspector set if it throws an exception
public void set baselining string baseline mode if off equals baseline mode nothing else if on equals baseline mode violation filters add new baseline violation filter else if set equals ignore case baseline mode violation filters add new baseline setup violation filter else throw new build exception invalid baselining mode baseline mode
sets baselining mode
public void set force on warnings boolean force on warnings this force on warnings force on warnings
force review of files with warnings even if the file is not changed
public void set database file database this database database
if this parameter is set then hypersonic standalone database
public void set tab size int tab size this tab size tab size
tab size in source files
public void visit operation operation if max parameters null operation get parameters size max parameters int value context report violation operation new object new integer operation get parameters size max parameters
reviews the method and checks if it has too many parameters
public boolean set parameter string name object value throws configuration exception if max parameters equals name max parameters new integer integer parse int value to string return true throw new configuration exception parameter name is not supported
configures the rule
public string get config info string buffer ret new string buffer allowed nbr of parameters n ret append max parameters max parameters n return ret to string
gives back the preconfigured values
public void visit type definition element if max nesting null int i 0 for language element parent element get parent parent null parent instanceof type definition parent parent get parent i if i max nesting int value context report violation element
reviews the type definition if it is an inner class which nesting
public string get config info string buffer ret new string buffer allowed maximum nesting for inner classes n ret append max nesting max nesting n return ret to string
gives back the preconfigured values
public void visit method call element if notify compare to element get name to string 0 if element get parameters size 0 context report violation source marker element
reviews the methodcalls if they are notify and so violate agains the
public int get series count return 2
returns the number of series in the dataset
public string get series name int series if series 0 return good else if series 1 return defect return n a
returns the name of a series
public int get item count int series return distinct values size
returns the number of items in a series
public double get xvalue int series int item if series 0 distinct values element at item defect criteria good return distinct values element at item else if series 1 distinct values element at item defect criteria defect return distinct values element at item return 0
returns the x value for an item within a series
public double get yvalue int series int item return new integer frequencies element at item if series 0 distinct values element at item defect criteria good return frequencies element at item else if series 1 distinct values element at item defect criteria defect return frequencies element at item return 0
returns the y value for an item within a series
public double get start xvalue int series int item return new integer distinct values element at item if series 0 distinct values element at item defect criteria good return distinct values element at item else if series 1 distinct values element at item defect criteria defect return distinct values element at item return 0
returns the starting x value for the specified series and item
public double get end xvalue int series int item bar width compute bar width job compute bar width if series 0 distinct values element at item defect criteria good return distinct values element at item bar width else if series 1 distinct values element at item defect criteria defect return distinct values element at item bar width return 0
returns the ending x value for the specified series and item
public double get start yvalue int series int item return new integer frequencies element at item if series 0 distinct values element at item defect criteria good return frequencies element at item else if series 1 distinct values element at item defect criteria defect return frequencies element at item return 0
returns the starting y value for the specified series and item
public double get end yvalue int series int item return new integer frequencies element at item if series 0 distinct values element at item defect criteria good return frequencies element at item else if series 1 distinct values element at item defect criteria defect return frequencies element at item return 0
returns the ending y value for the specified series and item
public void add change listener dataset change listener listener
registers an object for notification of changes to the dataset
public void remove change listener dataset change listener listener
deregisters an object for notification of changes to the dataset
public boolean set parameter string name object value throws configuration exception if true return true else throw new configuration exception parameter name is not supported
configures the rule
public void visit method call element primary expression method name element get name if method name instanceof dot list flat operands dot method name get flat operands method name primary expression flat operands get flat operands size 1 list parameters element get parameters if method name instanceof ident sleep equals ident method name get text parameters size 1 if check for while as parent language element element context report violation source marker element
reviews the methodcalls if they violate against the rule
private boolean check for while as parent language element le boolean found while le instanceof while statement while found while le get parent null le le get parent found while le instanceof while statement return found while
checks if the element is inside of a while loop or is one
public void visit compilation unit compilation unit throws jsel exception set imports new hash set iterator it compilation unit get imports iterator while it has next identifier id identifier it next if imports add id get value context report violation source marker id
reviews the compilation unit java source file for duplicated import
public void visit compilation unit compilation unit if compilation unit get package get name length 0 context report violation compilation unit
reviews the compilation unit java source file if the package
public void visit handler element get handler stack push element get parameter
reviews the try blocks if they contain calls
protected boolean check next lcurly token a token the token must be followed by a lcurly in the same column and the next line boolean violation false token lcurly next non whitespace a token if lcurly get type java token types lcurly if lcurly get line a token get line 1 lcurly get column a token get column violation true else violation true return violation
checks formatting for tokens that are follow opening curly brace like do
protected boolean check prev rcurly token a token the token must have e previous rcurly in the same column and the previous line token rcurly previous non whitespace a token boolean violation false if rcurly get type java token types rcurly if rcurly get line a token get line 1 rcurly get column a token get column violation true else violation true return violation
checks formatting for tokens that are successors of a closing curly brace
public void visit compilation unit cu if cu get types is empty context report violation cu
reviews the node
public void visit constructor constructor const list add constructor
reviews the constructor definitions and collects them
public void visit type definition element throws hammurapi exception accumulating visitor exception sink es new accumulating visitor exception sink constructor snooper rs new constructor snooper element accept new dispatching visitor rs es if rs const list size 1 constructor constructor constructor rs const list get 0 check constructor constructor if es get exceptions is empty es dump throw new hammurapi exception chained errs
reviews the type definition if it violates against the rule
private void check constructor constructor constructor if constructor get modifiers contains public constructor get parameters size 0 if is empty constructor get compound statement context report violation constructor else java util iterator statements constructor get compound statement get statements iterator int cntr 0 while statements has next statement statement statement statements next if statement instanceof super constructor call cntr if cntr 0 context report violation constructor
checks if the constructor violates against the rule
public void visit variable definition element todo shall check not only for variable definition but also for parameters superclasses casts and implemented interfaces so it might be better to visit identifier or something like this try if dis allowed includes contains element get type specification get type get name context report violation element catch jsel exception e context warn element e
reviews the variable definitions if they violate agains the rule
public void visit type definition element java util iterator iter element get fields iterator while iter has next field field field iter next if field instanceof variable definition variable definition vd variable definition field string name vd get name if name length min length int value context report violation vd
reviews the variable definitions if they have clashing names
public boolean set parameter string name object value throws configuration exception if min length equals name min length integer value else throw new configuration exception parameter name is not supported return true
configures the rule
public boolean set parameter string name object parameter throws configuration exception if include equals name string s parameter to string cutting the ending makes easier the later checks if s ends with star s s substring 0 s length sub str len dis allowed includes add s return true else throw new configuration exception parameter name is not supported by get class get name
configures the rule
public string get config info string buffer ret new string buffer allowed minimal length for instance variable names n ret append length min length n return ret to string
gives back the preconfigured values
public string get config info string buffer ret new string buffer disallowed types java util iterator iter dis allowed includes iterator while iter has next ret append n ttype string iter next ret append n return ret to string
gives back the preconfigured values
public void visit method call element language element lelement language element element repository repository lelement get compilation unit get package get repository try if language element element get enclosing type is kind of eb class name java util iterator iter element get parameters iterator while iter has next if iter next instanceof this context report violation lelement catch jsel exception e context warn lelement e
visits the methodcalls if they has this as parameter
protected boolean check next lcurly token a token the token must be followed by a lcurly in the same line boolean violation false token lcurly next non whitespace a token if lcurly get type java token types lcurly if lcurly get line a token get line violation true else violation true return violation
checks formatting for tokens that are follow opening curly brace like do
public void visit method call element try operation info provider element get provider if provider null context warn source marker element provider is null for element at language element element get location else if violation method equals provider get name provider get parameter types length 0 provider get declaring type is kind of violation class context report violation source marker element catch jsel exception e context warn source marker element e
reviews the methodcalls to yield since they are violations
protected boolean check prev rcurly token a token the token must have e previous rcurly in the same line token rcurly previous non whitespace a token boolean violation false if rcurly get type java token types rcurly if rcurly get line a token get line violation true else violation true return violation
checks formatting for tokens that are successors of a closing curly brace
public void visit try block try block if try block get finally clause null is empty try block get finally clause context report violation source marker try block get finally clause
reviews the node
protected token skip expression tokens token current token int open 0 token token current token do if token get type java token types lparen open if token get type java token types rparen open if open 0 token next non whitespace token while token null open 0 return token
skips all tokens of a expression in parenthesis
public void init db sqlprocessor processor properties db properties for int i 0 i init sql length i try processor process update init sql i null catch sqlexception e throw new hammurapi runtime exception e
creating a table to store results
protected token next non whitespace token a token token current token a token get next token while current get type java token types ws current get type java token types new line current token current get next token return current
skip all next tokens that are whitespaces
protected token previous non whitespace token a token token current token a token get prev token while current get type java token types ws current get type java token types new line current token current get prev token return current
skip all previous tokens that are whitespaces
public void visit compilation unit compilation unit throws jsel exception if compilation unit get types size 1 iterator it compilation unit get types iterator it next while it has next context report violation source marker it next
reviews the node
public boolean set parameter string name object parameter throws configuration exception if max lines equals name max line integer parameter else throw new configuration exception parameter name is not supported by get class get name return true
configures the rule
public void visit method element java util iterator parameters element get parameters iterator while parameters has next parameter parameter parameter parameters next string param name parameter get name try if element get enclosing scope get variable namespace find param name null context report violation parameter catch jsel exception e context warn parameter e
reviews the method definitions if they have parameters with the same
public string get config info if max line null return super get config info else string buffer ret new string buffer allowed maximum file length n ret append max lines max line n return ret to string
gives back the preconfigured values
public void visit switch statement statement iterator it statement get cases groups iterator while it has next cases group group cases group it next iterator cit group get cases iterator while cit has next if cit next instanceof default case iterator sit group get statements iterator while sit has next if is empty statement sit next return context report violation source marker statement default case is present but empty return context report violation source marker statement
reviews the switch statement
public void leave compilation unit cu throws hammurapi exception if disabled final source marker sm context detach cu final detailed results result results factory get thread results results factory get instance execute new results factory task public void execute throws hammurapi exception result add metric sm work order 100 0 math log clients 1 1 result get violation level 1
reviews the compilation unit if its file violates agaianst the rule
public string get config info string buffer ret new string buffer allowed maximum line length n ret append line max length max line length n return ret to string
gives back the preconfigured values
public void visit double constant element if is allowed element get value analyze language element element
reviews the double constant literals if they are allowed
public void visit float constant element if is allowed element get value analyze language element element
reviews the float constant literals if they are allowed
public void visit integer constant element if is allowed element get value analyze language element element
reviews the int constant literals if they are allowed
public void visit long constant element if is allowed element get value analyze language element element
reviews the long constant literals if they are allowed
private boolean is allowed double value return allowed literals contains new double value
checks if a double value is in the allowed list
public string get config info string buffer ret new string buffer allowed numeric literals n iterator it allowed literals iterator while it has next ret append t ret append it next ret append n return ret to string
gives back the preconfigured values
public boolean match string package name collection clients iterator it products iterator while it has next product product product it next if product match package name clients return true return false
matches package name and adds clients if matched
public void visit com pavelvlasov jsel class clazz java util iterator iter clazz get fields iterator while iter has next field field field iter next if field instanceof variable definition field get modifiers contains static variable definition vd variable definition field try if vd get type specification get type is kind of java util collection context report violation field catch jsel exception e context warn field e
reviews the type definition if it has static collection attributes