Commit 1c2a5f34 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

made new checks configurable

parent 2f854a90
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="de.ugoe.cs.swe.T3Q.T3Q"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--config config/t3q.cfg --profile defaultProfile resources/IMS_PART4_IWD_14wk37"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--config config/t3q.cfg --profile defaultProfile resources/IMS_PART4_IWD_15wk38"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="de.ugoe.cs.swe.T3Q"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx4g"/>
<stringAttribute key="yk-options" value="&#13;&#10;additional-options2=onexit\=snapshot&#13;&#10;"/>
+5 −1
Original line number Diff line number Diff line
@@ -50,7 +50,11 @@
      <checkNoUnusedImports>true</checkNoUnusedImports>
      <checkNoUnusedFormalParameters>true</checkNoUnusedFormalParameters>
      <checkNoUnusedLocalDefinitions>true</checkNoUnusedLocalDefinitions>
      <checkNoLiterals>true</checkNoLiterals>
      <checkNoLiterals>false</checkNoLiterals>
      <checkLevelOfNestedCalls>true</checkLevelOfNestedCalls>
      <maxLevelOfNestedCalls>4</maxLevelOfNestedCalls>
      <checkInlineTemplates>false</checkInlineTemplates>
      <checkListedVariableDeclarations>true</checkListedVariableDeclarations>
      <checkTypesAndValuesModuleContainmentCheck>true</checkTypesAndValuesModuleContainmentCheck>
      <checkTemplatesModuleContainmentCheck>true</checkTemplatesModuleContainmentCheck>
      <checkFunctionsModuleContainmentCheck>true</checkFunctionsModuleContainmentCheck>
+4 −0
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@
      <checkNoUnusedFormalParameters>true</checkNoUnusedFormalParameters>
      <checkNoUnusedLocalDefinitions>true</checkNoUnusedLocalDefinitions>
      <checkNoLiterals>false</checkNoLiterals>
      <checkLevelOfNestedCalls>true</checkLevelOfNestedCalls>
      <maxLevelOfNestedCalls>4</maxLevelOfNestedCalls>
      <checkInlineTemplates>false</checkInlineTemplates>
      <checkListedVariableDeclarations>true</checkListedVariableDeclarations>
      <checkTypesAndValuesModuleContainmentCheck>true</checkTypesAndValuesModuleContainmentCheck>
      <checkTemplatesModuleContainmentCheck>true</checkTemplatesModuleContainmentCheck>
      <checkFunctionsModuleContainmentCheck>true</checkFunctionsModuleContainmentCheck>
+13 −6
Original line number Diff line number Diff line
@@ -160,9 +160,11 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
	}

	@Check
	def checkNestedCalls(FunctionInstance instance) {
		// TODO: configuration for check and number of allowed nested calls
		val maxLevel = 3;
	def checkLevelOfNestedCalls(FunctionInstance instance) {
		if (!activeProfile.checkLevelOfNestedCalls)
			return;		
		
		val maxLevel = activeProfile.maxLevelOfNestedCalls;
		var depth = 1;
		var parent = instance;

@@ -191,7 +193,9 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {

	@Check
	def checkListedVariableDeclarations(TempVarList list) {
		// TODO: configuration for check
		if (!activeProfile.checkListedVariableDeclarations)
			return;		

		if (list.variables.size > 1) {
			statistics.incrementCountStyle
			val message = "Listed variable declarations are used!"
@@ -209,7 +213,9 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {

	@Check
	def checkListedVariableDeclarations(VarList list) {
		// TODO: configuration for check
		if (!activeProfile.checkListedVariableDeclarations)
			return;		

		if (list.variables.size > 1) {
			statistics.incrementCountStyle
			val message = "Listed variable declarations are used!"
@@ -228,7 +234,8 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
	@Check
	def checkInlineTemplates() {
		//TODO: implement this
		//TODO: configuration for this check
		if (!activeProfile.checkInlineTemplates)
			return;		
	}
	
	private def <T extends EObject> int nestingDepth(EObject o, Class<T> t) {
+45 −1
Original line number Diff line number Diff line
@@ -39,7 +39,10 @@ public class QualityCheckProfile extends ConfigurationProfile {
	private boolean checkNoUnusedFormalParameters = true;
	private boolean checkNoUnusedLocalDefinitions = true;
	private boolean checkNoLiterals = true;

	private boolean checkLevelOfNestedCalls = true;
	private int maxLevelOfNestedCalls = 4;
	private boolean checkInlineTemplates = false;
	private boolean checkListedVariableDeclarations = true;
	
	private boolean checkTypesAndValuesModuleContainmentCheck = true;
	private boolean checkTemplatesModuleContainmentCheck = true;
@@ -532,5 +535,46 @@ public class QualityCheckProfile extends ConfigurationProfile {
		return recursionInCheckNoOverSpecificRunsOnClauses;
	}

	public boolean isCheckLevelOfNestedCalls() {
		return checkLevelOfNestedCalls;
	}

	public void setCheckLevelOfNestedCalls(boolean checkLevelOfNestedCalls) {
		this.checkLevelOfNestedCalls = checkLevelOfNestedCalls;
	}

	public int getMaxLevelOfNestedCalls() {
		return maxLevelOfNestedCalls;
	}

	public void setMaxLevelOfNestedCalls(int maxLevelOfNestedCalls) {
		this.maxLevelOfNestedCalls = maxLevelOfNestedCalls;
	}

	public boolean isCheckInlineTemplates() {
		return checkInlineTemplates;
	}

	public void setCheckInlineTemplates(boolean checkInlineTemplates) {
		this.checkInlineTemplates = checkInlineTemplates;
	}

	public boolean isCheckListedVariableDeclarations() {
		return checkListedVariableDeclarations;
	}

	public void setCheckListedVariableDeclarations(boolean checkListedVariableDeclarations) {
		this.checkListedVariableDeclarations = checkListedVariableDeclarations;
	}

	public void setCheckTypesAndValuesModuleImportsLibNames(boolean checkTypesAndValuesModuleImportsLibNames) {
		this.checkTypesAndValuesModuleImportsLibNames = checkTypesAndValuesModuleImportsLibNames;
	}

	public void setTypesAndValuesImportsLibNamesRegExp(String typesAndValuesImportsLibNamesRegExp) {
		this.typesAndValuesImportsLibNamesRegExp = typesAndValuesImportsLibNamesRegExp;
	}

	

}