input stringlengths 10 828 | output stringlengths 5 107 |
|---|---|
public void visit variable definition element type body enclosing type element get enclosing type if enclosing type instanceof type definition type definition enclosing type get name equals element get name context report violation element | reviews the variable definitions if they have clashing names |
public void visit code element int first line element get ast get first token get line int last line element get ast get last token get line int length last line first line context add metric element code length length if max line null length max line int value context report violation element | reviews the method definitions if they are longer than the preconfigured |
public void visit cases group element java util iterator statements element get statements iterator language element le null while statements has next le language element statements next last statement must be break throw or return if le instanceof break statement le instanceof throw statement le instanceof return statement context report violation element | reviews the the switch case if it contains a break as its |
public boolean set parameter string name object parameter throws configuration exception if max lines equals name max line integer parameter 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 if max line null return super get config info else string buffer ret new string buffer allowed maximum line length of the methods n ret append max lines max line n return ret to string | gives back the preconfigured values |
public void visit assignment expression element if element instanceof logical or element instanceof conditional expression if element get operand 0 instanceof ident ident ident ident element get operand 0 if names contains ident get text context report violation source marker element | reviews the assignments |
private void get names declaration element collection names iterator it element iterator while it has next variable definition vd variable definition it next names add vd get name | gets the control variable name in for loop |
public void visit method element try if element get enclosing scope get variable namespace find element get name null context report violation element catch jsel exception e context warn element e | reviews the type definitions if they have clashing names among |
private void get names expression list element collection names iterator it element iterator while it has next object o it next if o instanceof assignment expression o instanceof logical or o instanceof conditional expression expression o get operand 0 instanceof ident names add ident expression o get operand 0 get text | gets the control variable name in for loop |
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 wait equals ident method name get text parameters size 0 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 |
public string get config info if max nesting null string buffer ret new string buffer allowed maximum logical nesting n ret append max nesting max nesting n return ret to string else return | gives back the preconfigured values |
public void visit type definition type definition if type definition get name index of 1 character is upper case type definition get name char at 0 context report violation type definition | reviews the name of the classes |
public void visit method method if method get name index of 1 character is lower case method get name char at 0 context report violation method | reviews the name of the methods |
public void visit variable definition variable definition if variable definition get modifiers contains static variable definition get modifiers contains final if serial version uid equals variable definition get name variable definition get name to upper case equals variable definition get name context report violation variable definition else if variable definition get name index of 1 character is lower case variable definition get name char at 0 context report violation variable definition | reviews the name of the attributes |
public void visit method call mc throws jsel exception if visitor stack get thread instance is in for statement class context report violation source marker mc method call from for loop | demonstrates usage of visitor stack |
public void visit parameter parameter if parameter get name index of 1 character is lower case parameter get name char at 0 context report violation parameter | reviews the name of the parameters |
public void visit for statement statement if statement get iterator null context report violation source marker statement | reviews the for statements |
public void visit package element simple source marker ssm new simple source marker 0 0 element get name length 0 element get name replace null int package size element get compilation units size if max package size null package size max package size int value context report violation ex ssm new object max package size new integer package size max if min package size null package size min package size int value context report violation ex ssm new object min package size new integer package size min | reviews the package if it contains more files than the allowed max |
public void visit handler exp handler type specification ts exp handler get parameter get type specification try if too general exceptions contains ts get name context report violation exp handler catch jsel exception e context warn exp handler e | reviews the exception handlers if they catch too general exceptions |
public boolean set parameter string name object parameter throws configuration exception if general exceptions equals name too general exceptions add parameter to string 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 maximum files per package n if max package size null ret append max files max package size n if min package size null ret append min files min package size n return ret to string | gives back the preconfigured values |
public string get config info string buffer ret new string buffer too general exceptions to be catched n java util iterator iter too general exceptions iterator while iter has next ret append general exception string iter next t ret append n return ret to string | gives back the preconfigured values |
public void visit method call call string call txt call get name to string if call txt index of super clone call 0 call get parameters size 0 returns add call | reviews the calls to super |
public void visit method element throws hammurapi exception if element get name compare to clone name 0 element get parameters size 0 accumulating visitor exception sink es new accumulating visitor exception sink method call snooper rs new method call snooper element accept new dispatching visitor rs es if rs returns size 1 context report violation element if es get exceptions is empty es dump throw new hammurapi exception chained errs | reviews the method definitions if they are clone and call |
public void visit variable definition variable definition language element parent variable definition get parent if parent instanceof type definition return local variable if type definition parent get modifiers contains private return private class list modifiers variable definition get modifiers if modifiers contains public if modifiers contains final if final allowed return else if modifiers contains static static final allowed return else context report violation variable definition else context report violation variable definition | reviews the variable definitions |
public void visit constructor element element accept new visitor public boolean visit object target if target instanceof method call method call mc method call target try operation info oi mc get provider if oi null context warn source marker mc provider is null for mc at language element mc get location else if oi get operation instanceof method method method method oi get operation if method get modifiers contains abstract method get enclosing type language element mc get enclosing type context report violation source marker mc catch jsel exception e context warn source marker mc e return true | reviews the constructor definitions if they violate against |
public string get config info string buffer ret new string buffer allowed for public fields n ret append static static final allowed t ret append final final allowed t return ret to string | gives back the preconfigured values |
public string get config info string buffer ret new string buffer import order n int order size import order length 1 for int i 0 i order size i ret append import order i n return ret to string | gives back the preconfigured values |
public void visit handler handler if is empty handler get compound statement context report violation handler | reviews the exception handlers |
public void visit operation operation java util iterator it operation get throws iterator while it has next type identifier ti type identifier it next try if too general exceptions contains ti get name context report violation ti catch jsel exception e context warn operation e | reviews the operations if they have too general exceptions in their |
public void visit parameter element try string fcn element get type specification get type get name if fcn null violation class equals fcn context report violation source marker element catch jsel exception e context warn source marker element e | reviews if the not allowed class is used |
public boolean set parameter string name object parameter throws configuration exception if general exceptions equals name too general exceptions add parameter to string return true throw new configuration exception parameter name is not supported by get class get name | configures the rule |
public void visit variable definition element try string fcn element get type specification get type get name if fcn null violation class equals fcn context report violation source marker element catch jsel exception e context warn source marker element e | reviews if the not allowed class is used |
public string get config info string buffer ret new string buffer not allowed exceptions n java util iterator iter too general exceptions iterator while iter has next ret append general exception string iter next t ret append n return ret to string | gives back the preconfigured values |
public void visit ident element try object obj element get provider string fcn null if obj instanceof variable definition fcn variable definition obj get type specification get type get name else if obj instanceof parameter fcn parameter obj get type specification get type get name if fcn null violation class compare to fcn 0 context report violation source marker element catch jsel exception e context warn source marker element e | reviews if the not allowed class is used |
public void visit operation element if element get throws size max throws int value context report violation element | reviews the operations if they have in their throws clause more |
public boolean set parameter string name object parameter throws configuration exception if max throws equals name max throws integer parameter return true throw new configuration exception parameter name is not supported by get class get name | configures the rule |
public string get config info if string buffer ret new string buffer allowed maximum item in the throws clause n check for null ret append max throws max throws n return ret to string | gives back the preconfigured values |
public string get config info string buffer ret new string buffer configured release resource method names n iterator it release resource method list iterator while it has next ret append it next n return ret to string | gives back the preconfigured values |
public void visit return statement statement returns add statement | reviews the return statement and adds to the list |
public void visit try block try block throws hammurapi exception if try block get finally clause null accumulating visitor exception sink es new accumulating visitor exception sink return snooper rs new return snooper visitable try block get finally clause accept new dispatching visitor rs es iterator it rs returns iterator while it has next context report violation source marker it next if es get exceptions is empty es dump throw new hammurapi exception there have been exceptions see above | reviews the try blokk |
public string get config info string buffer ret new string buffer configured vendor names text n iterator it vendor names iterator while it has next ret append it next n return ret to string | gives back the preconfigured values |
public void visit class a class init source marker a class check token a class get ast get first token get class level a class token a class get ast get last token | checks indentation of tokens of a class |
public void visit compilation unit compilation unit throws jsel exception iterator it compilation unit get imports iterator while it has next identifier id identifier it next int idx id get value last index of if idx 1 id get value substring 0 idx equals java lang context report violation source marker id | reviews the node |
public void visit interface an interface check token an interface get ast get first token get class level an interface token an interface get ast get last token | checks indentation of tokens of an interface |
public void visit for statement statement if statement get initializer null context report violation source marker statement | reviews the for statements |
public string get config info string buffer ret new string buffer allowed logger class n ret append logger class name logger class name n return ret to string | gives back the preconfigured values |
protected void init source marker language element an element source marker new simple source marker an element compilation unit unit an element get compilation unit package pack unit get package if pack get name length 0 source marker set source url unit get name else source marker set source url pack get name replace file separator char file separator unit get name | initializes the source marker for the current language element |
public void visit operation operation iterator it operation get throws iterator repository repository operation get compilation unit get package get repository while it has next type identifier ti type identifier it next try if ti is kind of java lang runtime exception context report violation ti catch jsel exception e context warn operation e | reviews the operations if they throw any runtime exception |
public boolean set parameter string name object value throws configuration exception if logger class equals name logger class value to string else if logger method equals name logger methods add value to string else throw new configuration exception parameter name is not supported return true | configures the rule |
public void visit operation operation int complexity operation get complexity context add metric operation operation complexity complexity anu 24th may 05 added check for the upper limit for er 011 yellow inspector if operation max red complexity null if operation max complexity null complexity operation max complexity int value complexity operation max red complexity int value context report violation operation new object operation max complexity new integer complexity else if operation max complexity null complexity operation max complexity int value context report violation operation new object operation max complexity new integer complexity | reviews the methods and calculates their complexity |
public string get config info string buffer ret new string buffer used logger class logger class n java util iterator iter logger methods iterator while iter has next ret append operation iter next to string t ret append n return ret to string | gives back the preconfigured values |
protected int get class level language element an element int class level 0 language element parent an element get parent while parent null parent instanceof class class level parent parent get parent return class level | counts the parent classes |
public void visit parameter parameter if parameter is final parameter get parent instanceof operation is empty operation parameter get parent get compound statement context report violation parameter | reviews the method parameters |
public void visit com pavelvlasov jsel class clazz int complexity clazz get complexity context add metric clazz class complexity complexity anu 24th may 05 added check for the upper limit for er 011 yellow inspector if class max red complexity null if class max complexity null complexity class max complexity int value complexity class max red complexity int value context report violation clazz new object class max complexity new integer complexity else if class max complexity null complexity class max complexity int value context report violation clazz new object class max complexity new integer complexity | reviews the class definition and calculates its complexity |
public void visit interface element java util iterator fields element get fields iterator while fields has next modifiable item modifiable fields next if allowed modifiers contains all item get modifiers context report violation item | reviews the interface definition if it has a declaration with |
public boolean set parameter string name object parameter throws configuration exception if allowed modifier equals name allowed modifiers add parameter to string return true else throw new configuration exception parameter name is not supported | configures the rule |
public string get config info string buffer ret new string buffer allowed modifiers in the interface declarations n java util iterator iter allowed modifiers iterator while iter has next ret append allowed modifier string iter next t ret append n return ret to string | gives back the preconfigured values |
public void visit long constant literal if literal get text ends with l context report violation source marker literal | reviews the long constant literal |
public string get config info string buffer ret new string buffer allowed cyclematic complexity n ret append operation operation max complexity t ret append class class max complexity n return ret to string | gives back the preconfigured values |
public void visit method method if method get modifiers contains synchronized context report violation method | reviews the methods if they are synchronized |
public void visit operation element java util iterator throws list element get throws iterator while throws list has next type identifier item type identifier throws list next try if allowed throws contains item get name context report violation element new object item catch jsel exception e context warn item e | reviews the operations if they have items in their throws clause which |
public void visit assignment expression expression if expression instanceof logical or expression instanceof conditional expression assignments add expression | reviews the assignment expression |
public boolean set parameter string name object parameter throws configuration exception if allowed throw equals name allowed throws add parameter to string return true else throw new configuration exception parameter name is not supported by get class get name | configures the rule |
public void visit if statement statement throws hammurapi exception assignment snooper snooper new assignment snooper accumulating visitor exception sink es new accumulating visitor exception sink dispatching visitor dv new dispatching visitor snooper es visitable statement get expression accept dv iterator it snooper assignments iterator while it has next context report violation source marker it next if es get exceptions is empty es dump throw new hammurapi exception there have been exceptions see above | reviews the if statement if it contains in its condition |
public string get config info string buffer ret new string buffer allowed exceptions in the thorws clauses n java util iterator iter allowed throws iterator while iter has next ret append allowed throw string iter next t ret append n return ret to string | gives back the preconfigured values |
public void visit compilation unit compilation unit string package name compilation unit get package get name anu 20050525 updated for matching the package name with the passed parameters iterator it root package iterator while it has next string root pkg string it next if root pkg null if package name equals root pkg package name starts with root pkg return else return context report violation compilation unit new object root package | reviews the node |
public void visit variable definition element try if element get type specification get type is kind of tg class name context report violation element catch jsel exception e context warn element e | reviews if the variable definition has the type thread group |
public string get config info string buffer ret new string buffer application root package n iterator it root package iterator while it has next ret append it next n return ret to string | gives back the preconfigured values |
public boolean set parameter string name object parameter throws configuration exception if exception equals name too general exceptions add parameter to string else throw new configuration exception parameter name is not supported by get class get name return true | configures the rule |
public string get config info string buffer ret new string buffer not allowed exceptions n java util iterator iter too general exceptions iterator while iter has next ret append exception string iter next t ret append n return ret to string | gives back the preconfigured values |
public boolean set parameter string name object parameter throws configuration exception if copyright equals name if copyrights contains parameter to string copyrights add parameter to string glob compiler compiler new glob compiler try patterns add compiler compile parameter to string catch malformed pattern exception e throw new configuration exception malformed pattern parameter e return true throw new configuration exception parameter name is not supported by get class get name | configures the rule |
public void visit for statement statement if statement get condition null context report violation source marker statement | reviews the for statements |
public string get config info string buffer ret new string buffer configured copyright text n iterator it copyrights iterator while it has next ret append it next n return ret to string | gives back the preconfigured values |
public void visit variable definition element if element get modifiers contains all modifiers element get type specification get dimensions 0 context report violation element | reviews the type definitions if they have public static final |
public void visit type body type body carry over previous state boolean decision boolean approvals peek boolean value evaluate only if package included if decision iterator it elements iterator while it has next element entry entry element entry it next try if entry name null entry operation signature null type body is kind of entry name decision entry exclude break catch jsel exception e if e get cause instanceof class not found exception context warn type body e break approvals push decision boolean true boolean false | includes excludes type only if package is included |
public void visit if statement statement if statement get statement instanceof compound statement context report violation source marker statement get statement if statement get else statement null statement get else statement instanceof compound statement statement get else statement instanceof if statement context report violation source marker statement get else statement | reviews the if statements |
public void visit do statement statement if statement get statement instanceof compound statement context report violation source marker statement get statement | reviews the do loops |
public void visit for statement statement if statement get statement instanceof compound statement context report violation source marker statement get statement | reviews the for loops |
public void visit while statement statement if statement get statement instanceof compound statement context report violation source marker statement get statement | reviews the while loops |
protected void add configurator parameterizable configurator configurators add configurator | adds a helper class configurator to the list of configurators |
public boolean set parameter string name object value throws configuration exception iterator it configurators iterator while it has next if parameterizable it next set parameter name value return true return false | iterates through configurators and passes parameter to them unless it is handled |
public void install instance this | makes this instance a singleton |
public void set reviews number long reviews this reviews reviews | sets number of reviews |
public void init inspectors throws configuration exception hammurapi exception iterator it get inspectors iterator while it has next inspector it next init | invokes init for all inspectors in the set |
public void destroy if inspectors null iterator it inspectors iterator while it has next inspector it next destroy | calls destroy for all inspectors |
public void execute task task throws hammurapi exception if task null synchronized tasks check terminated if tasks size max queue try tasks wait check terminated catch interrupted exception e throw new hammurapi exception e tasks add task tasks notify all | executes task in a separate thread |
public void set reviews number final long reviews this reviews reviews try factory get sqlprocessor process update update result set reviews where id new parameterizer public void parameterize prepared statement ps throws sqlexception ps set long 1 reviews ps set int 2 get id catch sqlexception e throw new hammurapi runtime exception e | sets number of reviews |
public void example valid if int a 1 int b 1 boolean ok false if a b b a ok true if a b b a a b b a a b 1 b a 1 ok true | correct indentation of an if statement |
public void example invalid if int a 1 int b 1 boolean ok false if a b b a ok true violation if a b b a ok true violation if a b b a a b b a violation b a b a violation b a a b violation ok true violation | violating indentation of an if statement |
public void example valid assignment string a very long name of avariable hello | correct indentation of an assignment |
public void example invalid assignment string a very long name of avariable hello violation a very long name of avariable hello violation | violating indentation of an assignment |
public void example valid method call string s abc s get class get class to string int l s length | correct indentation of a method call |
public void example invalid method call string s abc s to string violation int l s length violation | violating indentation of a method call |
public void example valid if int a 1 int b 1 boolean ok false if a b b a ok true if a b b a a b b a ok true | correct use of an if statement |
public void example invalid if int a 1 int b 1 boolean ok false violation if a b b a ok true violation if a b b a ok true | violating use of an if statement |
public void example valid do int a 1 int b 2 int c 1024 do a a b while a c | correct use of an do statement |
public int example invalid throws int value1 int value2 throws runtime exception violation return value1 value2 | violating indentation of throws usage |
public void example invalid do int a 1 int b 2 int c 1024 violation do a a b violation while a c violation do a a b violation while a c | violating use of an do statement |
public void example valid while int a 1 int b 2 int c 1024 while a c a a b | correct use of an while statement |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.