Commit d0225cb3 authored by Roxane Kang Maréchal's avatar Roxane Kang Maréchal
Browse files

Merge with master

parents 91cef39b 4eb8c8c7
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="ArrayIsStoredDirectly">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Foo">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier visibility="private"/>
<type type="//@orphanTypes.9"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="x" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@expression/@leftHandSide/@field"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="foo">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// Don't do this, make a copy of the array at least" prefixOfParent="true"/>
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0">
<leftHandSide xsi:type="java:FieldAccess" originalCompilationUnit="//@compilationUnits.0">
<field variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0"/>
<expression xsi:type="java:ThisExpression" originalCompilationUnit="//@compilationUnits.0"/>
</leftHandSide>
<rightHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="param" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@expression/@rightHandSide">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@elementType">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</orphanTypes>
<compilationUnits name="Foo.java" originalFilePath="C:\Users\vanni\eclipse-workspace\ArrayIsStoredDirectly\src\Foo.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0/@comments.0" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="AvoidInstantiatingObjectInLoops">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Main">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="main">
<modifier visibility="public" static="true"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ForStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="&lt;">
<rightOperand xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="10"/>
<leftOperand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@initializers.0/@fragments.0"/>
</expression>
<updaters xsi:type="java:PostfixExpression" originalCompilationUnit="//@compilationUnits.0">
<operand xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@initializers.0/@fragments.0"/>
</updaters>
<initializers xsi:type="java:VariableDeclarationExpression" originalCompilationUnit="//@compilationUnits.0">
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="i" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@expression/@leftOperand //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@updaters.0/@operand">
<initializer xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="0"/>
</fragments>
<modifier/>
</initializers>
<body xsi:type="java:Block" originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.0/@ownedElements.1"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="f">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0">
<type type="//@ownedElements.0/@ownedElements.1"/>
</initializer>
</fragments>
<modifier/>
</statements>
</body>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="args">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.1" name="Foo" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@body/@statements.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@body/@statements.0/@fragments.0/@initializer/@type">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Foo" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@body/@statements.0/@fragments.0/@initializer"/>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@elementType">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@initializers.0/@type"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</orphanTypes>
<compilationUnits name="Main.java" originalFilePath="C:\Users\vanni\eclipse-workspace\AvoidInstantiatingObjectInLoops\src\Main.java" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="Foo.java" originalFilePath="C:\Users\vanni\eclipse-workspace\AvoidInstantiatingObjectInLoops\src\Foo.java" types="//@ownedElements.0/@ownedElements.1"/>
</java:Model>
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="InefficientEmptyStringCheck">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Main">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="main">
<modifier visibility="public" static="true"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="str" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@leftOperand/@leftOperand/@expression/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@rightOperand/@expression/@expression">
<initializer xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;test&quot;"/>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:IfStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="||">
<rightOperand xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</rightOperand>
<leftOperand xsi:type="java:InfixExpression" originalCompilationUnit="//@compilationUnits.0" operator="==">
<rightOperand xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="0"/>
<leftOperand xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</leftOperand>
</leftOperand>
</expression>
<thenStatement xsi:type="java:Block" originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0">
<arguments xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;string is empty&quot;"/>
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0/@fragments.0">
<qualifier xsi:type="java:TypeAccess" type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</expression>
</expression>
</statements>
</thenStatement>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="args">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@elementType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@type //@ownedElements.1/@ownedPackages.1/@ownedElements.1/@bodyDeclarations.0/@parameters.0/@type">
<bodyDeclarations xsi:type="java:MethodDeclaration" name="trim" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@leftOperand/@leftOperand/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@rightOperand/@expression"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="length" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@leftOperand/@leftOperand"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="isEmpty" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@rightOperand"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
<ownedElements xsi:type="java:ClassDeclaration" name="System" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@thenStatement/@statements.0/@expression/@expression/@qualifier">
<bodyDeclarations xsi:type="java:FieldDeclaration" proxy="true">
<fragments name="out" proxy="true" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@thenStatement/@statements.0/@expression/@expression"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="AutoCloseable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.4/@superInterfaces.0"/>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Appendable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@superInterfaces.0"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
<ownedElements xsi:type="java:ClassDeclaration" name="PrintStream" proxy="true">
<bodyDeclarations xsi:type="java:MethodDeclaration" name="println" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@thenStatement/@statements.0/@expression">
<parameters name="arg0" proxy="true">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</parameters>
</bodyDeclarations>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.5"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.4"/>
<superClass type="//@ownedElements.1/@ownedPackages.1/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="FilterOutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.1/@superClass">
<superClass type="//@ownedElements.1/@ownedPackages.1/@ownedElements.3"/>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" name="OutputStream" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.2/@superClass">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.4"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.5"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Closeable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.3/@superInterfaces.0 //@ownedElements.1/@ownedPackages.1/@ownedElements.1/@superInterfaces.1">
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Flushable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.1/@ownedElements.3/@superInterfaces.1"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</orphanTypes>
<compilationUnits name="Main.java" originalFilePath="C:\Users\vanni\eclipse-workspace\InefficientEmptyStringCheck\src\Main.java" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="NullAssignmentTest">
<ownedElements name="fr">
<ownedPackages name="univnates">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="NullAssignmentTest">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier visibility="private"/>
<type type="//@orphanTypes.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="var" usageInVariableAccess="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@expression/@leftHandSide/@field"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:ConstructorDeclaration" originalCompilationUnit="//@compilationUnits.0" name="NullAssignmentTest">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:SuperConstructorInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0"/>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0">
<leftHandSide xsi:type="java:FieldAccess" originalCompilationUnit="//@compilationUnits.0">
<field variable="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@fragments.0"/>
<expression xsi:type="java:ThisExpression" originalCompilationUnit="//@compilationUnits.0"/>
</leftHandSide>
<rightHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0"/>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="var" usageInVariableAccess="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.1/@expression/@rightHandSide">
<modifier/>
<type type="//@orphanTypes.0"/>
</parameters>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="method">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// this is OK"/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="x" usageInVariableAccess="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.1/@expression/@leftHandSide //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.2/@expression/@leftHandSide">
<initializer xsi:type="java:NullLiteral" originalCompilationUnit="//@compilationUnits.0"/>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0">
<leftHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.0/@fragments.0"/>
<rightHandSide xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</rightHandSide>
</expression>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// big, complex piece of code here" prefixOfParent="true"/>
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// this is not required"/>
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// big, complex piece of code here"/>
<expression xsi:type="java:Assignment" originalCompilationUnit="//@compilationUnits.0">
<leftHandSide xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.0/@fragments.0"/>
<rightHandSide xsi:type="java:NullLiteral" originalCompilationUnit="//@compilationUnits.0"/>
</expression>
</statements>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedPackages>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="Object" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.0/@type //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.1/@expression/@rightHandSide/@type">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Object" proxy="true" usages="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@body/@statements.0 //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.1/@expression/@rightHandSide"/>
</ownedElements>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.0/@type //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@parameters.0/@type"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="NullAssignmentTest.java" originalFilePath="C:\Users\leber\eclipse-workspace\IDM-Projet\NullAssignmentTest\src\fr\univnates\NullAssignmentTest.java" commentList="//@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.0/@comments.0 //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.2/@comments.0 //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.2/@comments.1 //@ownedElements.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@body/@statements.2/@comments.2" package="//@ownedElements.0/@ownedPackages.0" types="//@ownedElements.0/@ownedPackages.0/@ownedElements.0"/>
</java:Model>
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="OneDeclarationPerLine">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Main">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="main">
<modifier visibility="public" static="true"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="name"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="lastname"/>
<modifier/>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="args">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@elementType //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@type">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</orphanTypes>
<compilationUnits name="Main.java" originalFilePath="C:\Users\vanni\eclipse-workspace\OneDeclarationPerLine\src\Main.java" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="SuspiciousHashcodeMethodName">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Main">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="main">
<modifier visibility="public" static="true"/>
<body originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// TODO Auto-generated method stub" enclosedByParent="true"/>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="args">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="hashcode">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:ReturnStatement" originalCompilationUnit="//@compilationUnits.0">
<expression xsi:type="java:NumberLiteral" originalCompilationUnit="//@compilationUnits.0" tokenValue="0"/>
</statements>
</body>
<returnType type="//@orphanTypes.0"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@elementType">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.1/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</orphanTypes>
<compilationUnits name="Main.java" originalFilePath="C:\Users\vanni\eclipse-workspace\SuspiciousHashcodeMethodName\src\Main.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@comments.0" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
This diff is collapsed.
library bestPractices; library bestPractices;
--------------------------------------------- AvoidPrintStackTrace --------------------------------------------- -- #TODO: Add comment
helper def: arrayIsStoredDirectly(): Set(smm!Measure) =
--Goes through all the methods to check if the following rule is followed: java!MethodDeclaration.allInstances()
--Avoid printStackTrace() ->select( md | md.parameters.size()>0)
helper def: avoidPrintStackTrace() : Set(smm!Measure) = ->select( md | md.parameters->exists(p | p.type.type.oclIsTypeOf(java!ArrayType)))
java!MethodInvocation.allInstances() ->select( md | md.parameters
-> select (m | m.method.name = 'printStackTrace') ->exists(p | p.methodDeclaration.body.statements
-> collect (m | thisModule.MeasureAvoidPrintStackTrace(m)) ->select(s | s.oclIsTypeOf(java!ExpressionStatement))
; ->select(s | s.expression.oclIsTypeOf(java!Assignment))
->exists(s | s.expression.rightHandSide.variable.name = p.name)
--------------------------------------------- AvoidFieldNameMatchingMethodName --------------------------------------------- )
)
->collect(md | thisModule.MeasureArrayIsStoredDirectly(md));
-- Rule for metrics AvoidFieldNameMatchingMethodName : return the set of class Measures that violates the rule. --- Rule for metrics AvoidFieldNameMatchingMethodName : return the set of class Measures that violates the rule.
helper def: avoidFieldNameMatchingMethodName() : Set(smm!Measure) = helper def: avoidFieldNameMatchingMethodName() : Set(smm!Measure) =
-- Browse through all class -- Browse through all class
java!ClassDeclaration.allInstances()->iterate(i; res : Set(smm!Measure) = Set{} | java!ClassDeclaration.allInstances()->iterate(i; res : Set(smm!Measure) = Set{} |
...@@ -28,116 +30,141 @@ helper def: avoidFieldNameMatchingMethodName() : Set(smm!Measure) = ...@@ -28,116 +30,141 @@ helper def: avoidFieldNameMatchingMethodName() : Set(smm!Measure) =
) )
); );
--------------------------------------------- EmptyStatementBlock ---------------------------------------------
--- Goes through all the methods to check if the following rule is followed:
--- Avoid printStackTrace()
helper def: avoidPrintStackTrace() : Set(smm!Measure) =
java!MethodInvocation.allInstances()
-> select (m | m.method.name = 'printStackTrace')
-> collect (m | thisModule.MeasureAvoidPrintStackTrace(m))
;
-- #TODO: Add comment
helper def: avoidReassigningParameters(): Set(smm!Measure) =
java!AbstractMethodDeclaration.allInstances()->select(method |
method.parameters.size() > 0 and not method.body.oclIsUndefined() -- need at least one parameter and a body
)->collect(method |
method.body.statements->select(statement |
statement.oclIsTypeOf(java!ExpressionStatement) -- statement must be an expression
)->collect(expressionStatement |
expressionStatement.expression
)->select(expression |
expression.oclIsTypeOf(java!Assignment) -- the expression must be an assignment
)->select(assignment |
assignment.leftHandSide.oclIsTypeOf(java!SingleVariableAccess) -- the receiving end of the assignment must be a variable access
)->select(assignment |
method.parameters->collect(singleVariableDeclaration |
singleVariableDeclaration.name -- for each parameter of the method we retrieve its name
)->includes(assignment.leftHandSide.variable.name) -- one of the parameter is on the receiving of an assignment
)->collect(assignment |
thisModule.MeasureAvoidReassigningParameters(assignment)
)
)->flatten();
--Detects the use of empty statements blocks. These blocks serve no purpose and should be removed --- Rule for metrics AvoidStringBufferField
-- TODO: improve comment
helper def: avoidStringBufferField() : Set(smm!Measure) =
java!FieldDeclaration.allInstances()
->select(dec | dec.type <> OclUndefined )
->select(dec | ( dec.type.type.name = 'StringBuffer' or dec.type.type.name = 'StringBuilder'))
->collect(dec | thisModule.MeasureAvoidStringBufferField(dec));
--- Detects the use of empty statements blocks. These blocks serve no purpose and should be removed
helper def: emptyStatementBlock() : Set(smm!Measure) = helper def: emptyStatementBlock() : Set(smm!Measure) =
java!Block.allInstances() java!Block.allInstances()
->select(block | block.statements.isEmpty()) ->select(block | block.statements.isEmpty())
->collect(block | thisModule.MeasureEmptyStatementBlock(block)); ->collect(block | thisModule.MeasureEmptyStatementBlock(block));
--------------------------------------------- SwitchDensity --------------------------------------------- --- Rule for metrics ForLoopVariableCount
-- Rule for metrics SwitchDensity : -- TODO: improve comment
helper def: switchDensity() : Set (smm!Measure) = helper def: forLoopVariableCount(): Set(smm!Measure) =
-- Browse through all Switch Statements java!ForStatement.allInstances()->select(forStatement |
java!SwitchStatement.allInstances()->iterate(switchCase; res : Set(smm!Measure) = Set{} | forStatement.nbLocalVariableDeclarations() > 1
switchCase.statements )->collect(forStatement | thisModule.MeasureForLoopVariableCount(forStatement));
->select(switchStatement | switchStatement.oclIsTypeOf(java!Block))
->select(switchStatement | switchStatement.statements <> OclUndefined)
->select(switchStatement | switchStatement.statements.size() -1 >= 10)
->collect(switchStatement | thisModule.MeasureSwitchDensity(switchCase))
);
--------------------------------------------- useAssertTrueInsteadOfAssertEquals ---------------------------------------------
helper def: useAssertTrueInsteadOfAssertEquals() : Set(smm!Measure) =
-- Browse through all methods use
java!MethodInvocation.allInstances()
--Check if the method use is assertEqual and a Boolean is used
->select(assert | assert.method.name = 'assertEquals')
->select(assert | thisModule.isWrongUseAssertTrueInsteadOfAssertEquals(assert))
->collect(assert | thisModule.MesureUseAssertTrueInsteadOfAssertEquals(assert));
helper def: isWrongUseAssertTrueInsteadOfAssertEquals(m:java!MethodInvocation) : Boolean = --- Checks if it's a BooleanLiteral
--Shorten the path m.arguments.last() to lastArgument and check if it's a boolean
let lastArgument : java!Expression = m.arguments.last() in lastArgument.isBoolean();
--Checks if it's a BooleanLiteral
helper context java!BooleanLiteral def: isBoolean() : Boolean = true; helper context java!BooleanLiteral def: isBoolean() : Boolean = true;
--Checks if the type of a Expression is Boolean
--- Checks if the type of a Expression is Boolean
helper context java!Expression def: isBoolean() : Boolean = helper context java!Expression def: isBoolean() : Boolean =
self.variable.variablesContainer.isBoolean(); self.variable.variablesContainer.isBoolean();
--Checks if the type of a VariableDeclarationStatement is Boolean
--- Checks if the type of a VariableDeclarationStatement is Boolean