@@ -59,7 +59,7 @@ public final class DirectoriesDecorator implements Decorator { | |||
if (Resource.QUALIFIER_DIRECTORY.equals(resource.getQualifier())) { | |||
context.saveMeasure(CoreMetrics.DIRECTORIES, 1.0); | |||
} else if (ResourceUtils.isSet(resource) || ResourceUtils.isView(resource) || ResourceUtils.isSubview(resource)) { | |||
} else if (ResourceUtils.isSet(resource)) { | |||
Collection<Measure> childrenMeasures = context.getChildrenMeasures(CoreMetrics.DIRECTORIES); | |||
Double sum = MeasureUtils.sum(false, childrenMeasures); | |||
if (sum != null) { |
@@ -138,14 +138,6 @@ public final class Constants { | |||
* <code>FILE = 3;</code> | |||
*/ | |||
FILE(3, 3), | |||
/** | |||
* <code>VIEW = 4;</code> | |||
*/ | |||
VIEW(4, 4), | |||
/** | |||
* <code>SUBVIEW = 5;</code> | |||
*/ | |||
SUBVIEW(5, 5), | |||
; | |||
/** | |||
@@ -164,14 +156,6 @@ public final class Constants { | |||
* <code>FILE = 3;</code> | |||
*/ | |||
public static final int FILE_VALUE = 3; | |||
/** | |||
* <code>VIEW = 4;</code> | |||
*/ | |||
public static final int VIEW_VALUE = 4; | |||
/** | |||
* <code>SUBVIEW = 5;</code> | |||
*/ | |||
public static final int SUBVIEW_VALUE = 5; | |||
public final int getNumber() { return value; } | |||
@@ -182,8 +166,6 @@ public final class Constants { | |||
case 1: return MODULE; | |||
case 2: return DIRECTORY; | |||
case 3: return FILE; | |||
case 4: return VIEW; | |||
case 5: return SUBVIEW; | |||
default: return null; | |||
} | |||
} | |||
@@ -795,29 +777,29 @@ public final class Constants { | |||
java.lang.String[] descriptorData = { | |||
"\n\017constants.proto*E\n\010Severity\022\010\n\004INFO\020\000\022" + | |||
"\t\n\005MINOR\020\001\022\t\n\005MAJOR\020\002\022\014\n\010CRITICAL\020\003\022\013\n\007B" + | |||
"LOCKER\020\004*X\n\rComponentType\022\013\n\007PROJECT\020\000\022\n" + | |||
"\n\006MODULE\020\001\022\r\n\tDIRECTORY\020\002\022\010\n\004FILE\020\003\022\010\n\004V" + | |||
"IEW\020\004\022\013\n\007SUBVIEW\020\005*J\n\020MeasureValueType\022\007" + | |||
"\n\003INT\020\000\022\010\n\004LONG\020\001\022\n\n\006DOUBLE\020\002\022\013\n\007BOOLEAN" + | |||
"\020\003\022\n\n\006STRING\020\004*\'\n\rEventCategory\022\t\n\005ALERT" + | |||
"\020\000\022\013\n\007PROFILE\020\001*F\n\021ComponentLinkType\022\010\n\004" + | |||
"HOME\020\000\022\007\n\003SCM\020\001\022\013\n\007SCM_DEV\020\002\022\t\n\005ISSUE\020\003\022" + | |||
"\006\n\002CI\020\004*\265\001\n\020HighlightingType\022\016\n\nANNOTATI", | |||
"ON\020\000\022\014\n\010CONSTANT\020\001\022\013\n\007COMMENT\020\002\022\013\n\007CPP_D" + | |||
"OC\020\003\022\026\n\022STRUCTURED_COMMENT\020\004\022\013\n\007KEYWORD\020" + | |||
"\005\022\027\n\023HIGHLIGHTING_STRING\020\006\022\021\n\rKEYWORD_LI" + | |||
"GHT\020\007\022\030\n\024PREPROCESS_DIRECTIVE\020\010*9\n\nTestS" + | |||
"tatus\022\006\n\002OK\020\001\022\013\n\007FAILURE\020\002\022\t\n\005ERROR\020\003\022\013\n" + | |||
"\007SKIPPED\020\004B\034\n\030org.sonar.batch.protocolH\001" | |||
"LOCKER\020\004*A\n\rComponentType\022\013\n\007PROJECT\020\000\022\n" + | |||
"\n\006MODULE\020\001\022\r\n\tDIRECTORY\020\002\022\010\n\004FILE\020\003*J\n\020M" + | |||
"easureValueType\022\007\n\003INT\020\000\022\010\n\004LONG\020\001\022\n\n\006DO" + | |||
"UBLE\020\002\022\013\n\007BOOLEAN\020\003\022\n\n\006STRING\020\004*\'\n\rEvent" + | |||
"Category\022\t\n\005ALERT\020\000\022\013\n\007PROFILE\020\001*F\n\021Comp" + | |||
"onentLinkType\022\010\n\004HOME\020\000\022\007\n\003SCM\020\001\022\013\n\007SCM_" + | |||
"DEV\020\002\022\t\n\005ISSUE\020\003\022\006\n\002CI\020\004*\265\001\n\020Highlightin" + | |||
"gType\022\016\n\nANNOTATION\020\000\022\014\n\010CONSTANT\020\001\022\013\n\007C", | |||
"OMMENT\020\002\022\013\n\007CPP_DOC\020\003\022\026\n\022STRUCTURED_COMM" + | |||
"ENT\020\004\022\013\n\007KEYWORD\020\005\022\027\n\023HIGHLIGHTING_STRIN" + | |||
"G\020\006\022\021\n\rKEYWORD_LIGHT\020\007\022\030\n\024PREPROCESS_DIR" + | |||
"ECTIVE\020\010*9\n\nTestStatus\022\006\n\002OK\020\001\022\013\n\007FAILUR" + | |||
"E\020\002\022\t\n\005ERROR\020\003\022\013\n\007SKIPPED\020\004B\034\n\030org.sonar" + | |||
".batch.protocolH\001" | |||
}; | |||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = | |||
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { | |||
public com.google.protobuf.ExtensionRegistry assignDescriptors( | |||
com.google.protobuf.Descriptors.FileDescriptor root) { | |||
descriptor = root; | |||
return null; | |||
} | |||
}; | |||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { | |||
public com.google.protobuf.ExtensionRegistry assignDescriptors( | |||
com.google.protobuf.Descriptors.FileDescriptor root) { | |||
descriptor = root; | |||
return null; | |||
} | |||
}; | |||
com.google.protobuf.Descriptors.FileDescriptor | |||
.internalBuildGeneratedFileFrom(descriptorData, | |||
new com.google.protobuf.Descriptors.FileDescriptor[] { |
@@ -8,10 +8,10 @@ public final class BatchInput { | |||
public static void registerAllExtensions( | |||
com.google.protobuf.ExtensionRegistry registry) { | |||
} | |||
public interface ServerIssueOrBuilder extends | |||
// @@protoc_insertion_point(interface_extends:ServerIssue) | |||
com.google.protobuf.MessageOrBuilder { | |||
public interface ServerIssueOrBuilder | |||
extends com.google.protobuf.MessageOrBuilder { | |||
// optional string key = 1; | |||
/** | |||
* <code>optional string key = 1;</code> | |||
*/ | |||
@@ -26,6 +26,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getKeyBytes(); | |||
// optional string module_key = 2; | |||
/** | |||
* <code>optional string module_key = 2;</code> | |||
*/ | |||
@@ -40,6 +41,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getModuleKeyBytes(); | |||
// optional string path = 3; | |||
/** | |||
* <code>optional string path = 3;</code> | |||
*/ | |||
@@ -54,6 +56,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getPathBytes(); | |||
// optional string rule_repository = 4; | |||
/** | |||
* <code>optional string rule_repository = 4;</code> | |||
*/ | |||
@@ -68,6 +71,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getRuleRepositoryBytes(); | |||
// optional string rule_key = 5; | |||
/** | |||
* <code>optional string rule_key = 5;</code> | |||
*/ | |||
@@ -82,6 +86,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getRuleKeyBytes(); | |||
// optional int32 line = 6; | |||
/** | |||
* <code>optional int32 line = 6;</code> | |||
*/ | |||
@@ -91,6 +96,7 @@ public final class BatchInput { | |||
*/ | |||
int getLine(); | |||
// optional string msg = 7; | |||
/** | |||
* <code>optional string msg = 7;</code> | |||
*/ | |||
@@ -105,6 +111,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getMsgBytes(); | |||
// optional .Severity severity = 8; | |||
/** | |||
* <code>optional .Severity severity = 8;</code> | |||
*/ | |||
@@ -114,6 +121,7 @@ public final class BatchInput { | |||
*/ | |||
org.sonar.batch.protocol.Constants.Severity getSeverity(); | |||
// optional bool manual_severity = 9; | |||
/** | |||
* <code>optional bool manual_severity = 9;</code> | |||
*/ | |||
@@ -123,6 +131,7 @@ public final class BatchInput { | |||
*/ | |||
boolean getManualSeverity(); | |||
// optional string resolution = 10; | |||
/** | |||
* <code>optional string resolution = 10;</code> | |||
*/ | |||
@@ -137,6 +146,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getResolutionBytes(); | |||
// optional string status = 11; | |||
/** | |||
* <code>optional string status = 11;</code> | |||
*/ | |||
@@ -151,6 +161,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getStatusBytes(); | |||
// optional string checksum = 12; | |||
/** | |||
* <code>optional string checksum = 12;</code> | |||
*/ | |||
@@ -165,6 +176,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getChecksumBytes(); | |||
// optional string assignee_login = 13; | |||
/** | |||
* <code>optional string assignee_login = 13;</code> | |||
*/ | |||
@@ -179,6 +191,7 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getAssigneeLoginBytes(); | |||
// optional int64 creation_date = 14; | |||
/** | |||
* <code>optional int64 creation_date = 14;</code> | |||
*/ | |||
@@ -192,9 +205,8 @@ public final class BatchInput { | |||
* Protobuf type {@code ServerIssue} | |||
*/ | |||
public static final class ServerIssue extends | |||
com.google.protobuf.GeneratedMessage implements | |||
// @@protoc_insertion_point(message_implements:ServerIssue) | |||
ServerIssueOrBuilder { | |||
com.google.protobuf.GeneratedMessage | |||
implements ServerIssueOrBuilder { | |||
// Use ServerIssue.newBuilder() to construct. | |||
private ServerIssue(com.google.protobuf.GeneratedMessage.Builder<?> builder) { | |||
super(builder); | |||
@@ -241,33 +253,28 @@ public final class BatchInput { | |||
break; | |||
} | |||
case 10: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000001; | |||
key_ = bs; | |||
key_ = input.readBytes(); | |||
break; | |||
} | |||
case 18: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000002; | |||
moduleKey_ = bs; | |||
moduleKey_ = input.readBytes(); | |||
break; | |||
} | |||
case 26: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000004; | |||
path_ = bs; | |||
path_ = input.readBytes(); | |||
break; | |||
} | |||
case 34: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000008; | |||
ruleRepository_ = bs; | |||
ruleRepository_ = input.readBytes(); | |||
break; | |||
} | |||
case 42: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000010; | |||
ruleKey_ = bs; | |||
ruleKey_ = input.readBytes(); | |||
break; | |||
} | |||
case 48: { | |||
@@ -276,9 +283,8 @@ public final class BatchInput { | |||
break; | |||
} | |||
case 58: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000040; | |||
msg_ = bs; | |||
msg_ = input.readBytes(); | |||
break; | |||
} | |||
case 64: { | |||
@@ -298,27 +304,23 @@ public final class BatchInput { | |||
break; | |||
} | |||
case 82: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000200; | |||
resolution_ = bs; | |||
resolution_ = input.readBytes(); | |||
break; | |||
} | |||
case 90: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000400; | |||
status_ = bs; | |||
status_ = input.readBytes(); | |||
break; | |||
} | |||
case 98: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000800; | |||
checksum_ = bs; | |||
checksum_ = input.readBytes(); | |||
break; | |||
} | |||
case 106: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00001000; | |||
assigneeLogin_ = bs; | |||
assigneeLogin_ = input.readBytes(); | |||
break; | |||
} | |||
case 112: { | |||
@@ -366,6 +368,7 @@ public final class BatchInput { | |||
} | |||
private int bitField0_; | |||
// optional string key = 1; | |||
public static final int KEY_FIELD_NUMBER = 1; | |||
private java.lang.Object key_; | |||
/** | |||
@@ -408,6 +411,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string module_key = 2; | |||
public static final int MODULE_KEY_FIELD_NUMBER = 2; | |||
private java.lang.Object moduleKey_; | |||
/** | |||
@@ -450,6 +454,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string path = 3; | |||
public static final int PATH_FIELD_NUMBER = 3; | |||
private java.lang.Object path_; | |||
/** | |||
@@ -492,6 +497,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string rule_repository = 4; | |||
public static final int RULE_REPOSITORY_FIELD_NUMBER = 4; | |||
private java.lang.Object ruleRepository_; | |||
/** | |||
@@ -534,6 +540,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string rule_key = 5; | |||
public static final int RULE_KEY_FIELD_NUMBER = 5; | |||
private java.lang.Object ruleKey_; | |||
/** | |||
@@ -576,6 +583,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional int32 line = 6; | |||
public static final int LINE_FIELD_NUMBER = 6; | |||
private int line_; | |||
/** | |||
@@ -591,6 +599,7 @@ public final class BatchInput { | |||
return line_; | |||
} | |||
// optional string msg = 7; | |||
public static final int MSG_FIELD_NUMBER = 7; | |||
private java.lang.Object msg_; | |||
/** | |||
@@ -633,6 +642,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional .Severity severity = 8; | |||
public static final int SEVERITY_FIELD_NUMBER = 8; | |||
private org.sonar.batch.protocol.Constants.Severity severity_; | |||
/** | |||
@@ -648,6 +658,7 @@ public final class BatchInput { | |||
return severity_; | |||
} | |||
// optional bool manual_severity = 9; | |||
public static final int MANUAL_SEVERITY_FIELD_NUMBER = 9; | |||
private boolean manualSeverity_; | |||
/** | |||
@@ -663,6 +674,7 @@ public final class BatchInput { | |||
return manualSeverity_; | |||
} | |||
// optional string resolution = 10; | |||
public static final int RESOLUTION_FIELD_NUMBER = 10; | |||
private java.lang.Object resolution_; | |||
/** | |||
@@ -705,6 +717,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string status = 11; | |||
public static final int STATUS_FIELD_NUMBER = 11; | |||
private java.lang.Object status_; | |||
/** | |||
@@ -747,6 +760,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string checksum = 12; | |||
public static final int CHECKSUM_FIELD_NUMBER = 12; | |||
private java.lang.Object checksum_; | |||
/** | |||
@@ -789,6 +803,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string assignee_login = 13; | |||
public static final int ASSIGNEE_LOGIN_FIELD_NUMBER = 13; | |||
private java.lang.Object assigneeLogin_; | |||
/** | |||
@@ -831,6 +846,7 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional int64 creation_date = 14; | |||
public static final int CREATION_DATE_FIELD_NUMBER = 14; | |||
private long creationDate_; | |||
/** | |||
@@ -865,8 +881,7 @@ public final class BatchInput { | |||
private byte memoizedIsInitialized = -1; | |||
public final boolean isInitialized() { | |||
byte isInitialized = memoizedIsInitialized; | |||
if (isInitialized == 1) return true; | |||
if (isInitialized == 0) return false; | |||
if (isInitialized != -1) return isInitialized == 1; | |||
memoizedIsInitialized = 1; | |||
return true; | |||
@@ -1064,9 +1079,8 @@ public final class BatchInput { | |||
* Protobuf type {@code ServerIssue} | |||
*/ | |||
public static final class Builder extends | |||
com.google.protobuf.GeneratedMessage.Builder<Builder> implements | |||
// @@protoc_insertion_point(builder_implements:ServerIssue) | |||
org.sonar.batch.protocol.input.BatchInput.ServerIssueOrBuilder { | |||
com.google.protobuf.GeneratedMessage.Builder<Builder> | |||
implements org.sonar.batch.protocol.input.BatchInput.ServerIssueOrBuilder { | |||
public static final com.google.protobuf.Descriptors.Descriptor | |||
getDescriptor() { | |||
return org.sonar.batch.protocol.input.BatchInput.internal_static_ServerIssue_descriptor; | |||
@@ -1316,6 +1330,7 @@ public final class BatchInput { | |||
} | |||
private int bitField0_; | |||
// optional string key = 1; | |||
private java.lang.Object key_ = ""; | |||
/** | |||
* <code>optional string key = 1;</code> | |||
@@ -1329,12 +1344,9 @@ public final class BatchInput { | |||
public java.lang.String getKey() { | |||
java.lang.Object ref = key_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
key_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
key_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1392,6 +1404,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string module_key = 2; | |||
private java.lang.Object moduleKey_ = ""; | |||
/** | |||
* <code>optional string module_key = 2;</code> | |||
@@ -1405,12 +1418,9 @@ public final class BatchInput { | |||
public java.lang.String getModuleKey() { | |||
java.lang.Object ref = moduleKey_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
moduleKey_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
moduleKey_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1468,6 +1478,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string path = 3; | |||
private java.lang.Object path_ = ""; | |||
/** | |||
* <code>optional string path = 3;</code> | |||
@@ -1481,12 +1492,9 @@ public final class BatchInput { | |||
public java.lang.String getPath() { | |||
java.lang.Object ref = path_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
path_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
path_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1544,6 +1552,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string rule_repository = 4; | |||
private java.lang.Object ruleRepository_ = ""; | |||
/** | |||
* <code>optional string rule_repository = 4;</code> | |||
@@ -1557,12 +1566,9 @@ public final class BatchInput { | |||
public java.lang.String getRuleRepository() { | |||
java.lang.Object ref = ruleRepository_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
ruleRepository_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
ruleRepository_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1620,6 +1626,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string rule_key = 5; | |||
private java.lang.Object ruleKey_ = ""; | |||
/** | |||
* <code>optional string rule_key = 5;</code> | |||
@@ -1633,12 +1640,9 @@ public final class BatchInput { | |||
public java.lang.String getRuleKey() { | |||
java.lang.Object ref = ruleKey_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
ruleKey_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
ruleKey_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1696,6 +1700,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional int32 line = 6; | |||
private int line_ ; | |||
/** | |||
* <code>optional int32 line = 6;</code> | |||
@@ -1728,6 +1733,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string msg = 7; | |||
private java.lang.Object msg_ = ""; | |||
/** | |||
* <code>optional string msg = 7;</code> | |||
@@ -1741,12 +1747,9 @@ public final class BatchInput { | |||
public java.lang.String getMsg() { | |||
java.lang.Object ref = msg_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
msg_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
msg_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1804,6 +1807,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional .Severity severity = 8; | |||
private org.sonar.batch.protocol.Constants.Severity severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; | |||
/** | |||
* <code>optional .Severity severity = 8;</code> | |||
@@ -1839,6 +1843,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional bool manual_severity = 9; | |||
private boolean manualSeverity_ ; | |||
/** | |||
* <code>optional bool manual_severity = 9;</code> | |||
@@ -1871,6 +1876,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string resolution = 10; | |||
private java.lang.Object resolution_ = ""; | |||
/** | |||
* <code>optional string resolution = 10;</code> | |||
@@ -1884,12 +1890,9 @@ public final class BatchInput { | |||
public java.lang.String getResolution() { | |||
java.lang.Object ref = resolution_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
resolution_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
resolution_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -1947,6 +1950,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string status = 11; | |||
private java.lang.Object status_ = ""; | |||
/** | |||
* <code>optional string status = 11;</code> | |||
@@ -1960,12 +1964,9 @@ public final class BatchInput { | |||
public java.lang.String getStatus() { | |||
java.lang.Object ref = status_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
status_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
status_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -2023,6 +2024,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string checksum = 12; | |||
private java.lang.Object checksum_ = ""; | |||
/** | |||
* <code>optional string checksum = 12;</code> | |||
@@ -2036,12 +2038,9 @@ public final class BatchInput { | |||
public java.lang.String getChecksum() { | |||
java.lang.Object ref = checksum_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
checksum_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
checksum_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -2099,6 +2098,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string assignee_login = 13; | |||
private java.lang.Object assigneeLogin_ = ""; | |||
/** | |||
* <code>optional string assignee_login = 13;</code> | |||
@@ -2112,12 +2112,9 @@ public final class BatchInput { | |||
public java.lang.String getAssigneeLogin() { | |||
java.lang.Object ref = assigneeLogin_; | |||
if (!(ref instanceof java.lang.String)) { | |||
com.google.protobuf.ByteString bs = | |||
(com.google.protobuf.ByteString) ref; | |||
java.lang.String s = bs.toStringUtf8(); | |||
if (bs.isValidUtf8()) { | |||
assigneeLogin_ = s; | |||
} | |||
java.lang.String s = ((com.google.protobuf.ByteString) ref) | |||
.toStringUtf8(); | |||
assigneeLogin_ = s; | |||
return s; | |||
} else { | |||
return (java.lang.String) ref; | |||
@@ -2175,6 +2172,7 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional int64 creation_date = 14; | |||
private long creationDate_ ; | |||
/** | |||
* <code>optional int64 creation_date = 14;</code> | |||
@@ -2218,7 +2216,7 @@ public final class BatchInput { | |||
// @@protoc_insertion_point(class_scope:ServerIssue) | |||
} | |||
private static final com.google.protobuf.Descriptors.Descriptor | |||
private static com.google.protobuf.Descriptors.Descriptor | |||
internal_static_ServerIssue_descriptor; | |||
private static | |||
com.google.protobuf.GeneratedMessage.FieldAccessorTable | |||
@@ -2243,25 +2241,24 @@ public final class BatchInput { | |||
" \001(\003B\"\n\036org.sonar.batch.protocol.inputH\001" | |||
}; | |||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = | |||
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { | |||
public com.google.protobuf.ExtensionRegistry assignDescriptors( | |||
com.google.protobuf.Descriptors.FileDescriptor root) { | |||
descriptor = root; | |||
return null; | |||
} | |||
}; | |||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { | |||
public com.google.protobuf.ExtensionRegistry assignDescriptors( | |||
com.google.protobuf.Descriptors.FileDescriptor root) { | |||
descriptor = root; | |||
internal_static_ServerIssue_descriptor = | |||
getDescriptor().getMessageTypes().get(0); | |||
internal_static_ServerIssue_fieldAccessorTable = new | |||
com.google.protobuf.GeneratedMessage.FieldAccessorTable( | |||
internal_static_ServerIssue_descriptor, | |||
new java.lang.String[] { "Key", "ModuleKey", "Path", "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "ManualSeverity", "Resolution", "Status", "Checksum", "AssigneeLogin", "CreationDate", }); | |||
return null; | |||
} | |||
}; | |||
com.google.protobuf.Descriptors.FileDescriptor | |||
.internalBuildGeneratedFileFrom(descriptorData, | |||
new com.google.protobuf.Descriptors.FileDescriptor[] { | |||
org.sonar.batch.protocol.Constants.getDescriptor(), | |||
}, assigner); | |||
internal_static_ServerIssue_descriptor = | |||
getDescriptor().getMessageTypes().get(0); | |||
internal_static_ServerIssue_fieldAccessorTable = new | |||
com.google.protobuf.GeneratedMessage.FieldAccessorTable( | |||
internal_static_ServerIssue_descriptor, | |||
new java.lang.String[] { "Key", "ModuleKey", "Path", "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "ManualSeverity", "Resolution", "Status", "Checksum", "AssigneeLogin", "CreationDate", }); | |||
org.sonar.batch.protocol.Constants.getDescriptor(); | |||
} | |||
// @@protoc_insertion_point(outer_class_scope) |
@@ -35,8 +35,6 @@ enum ComponentType { | |||
MODULE = 1; | |||
DIRECTORY = 2; | |||
FILE = 3; | |||
VIEW = 4; | |||
SUBVIEW = 5; | |||
} | |||
enum MeasureValueType { |
@@ -19,14 +19,12 @@ | |||
*/ | |||
package org.sonar.batch.components; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.api.batch.RequiresDB; | |||
import org.sonar.api.database.DatabaseSession; | |||
import org.sonar.api.database.model.Snapshot; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.batch.deprecated.components.PeriodsDefinition; | |||
import javax.annotation.CheckForNull; | |||
@@ -63,7 +61,7 @@ public class TimeMachineConfiguration implements BatchComponent { | |||
modulePastSnapshots.add(pastSnapshot); | |||
// When no snapshot is found, date of the period is null | |||
periods.add(new Period(pastSnapshot.getIndex(), snapshot != null ? longToDate(snapshot.getCreatedAtMs()) : null)); | |||
log(pastSnapshot); | |||
LOG.info(pastSnapshot.toString()); | |||
} | |||
} | |||
@@ -82,16 +80,6 @@ public class TimeMachineConfiguration implements BatchComponent { | |||
return snapshots.isEmpty() ? null : snapshots.get(0); | |||
} | |||
private void log(PastSnapshot pastSnapshot) { | |||
String qualifier = pastSnapshot.getQualifier(); | |||
// hack to avoid too many logs when the views plugin is installed | |||
if (StringUtils.equals(Qualifiers.VIEW, qualifier) || StringUtils.equals(Qualifiers.SUBVIEW, qualifier)) { | |||
LOG.debug(pastSnapshot.toString()); | |||
} else { | |||
LOG.info(pastSnapshot.toString()); | |||
} | |||
} | |||
public List<Period> periods() { | |||
return periods; | |||
} |
@@ -37,7 +37,6 @@ import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.utils.KeyValueFormat; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.batch.cpd.index.IndexFactory; | |||
import org.sonar.batch.cpd.index.SonarDuplicationsIndex; | |||
@@ -60,17 +59,10 @@ import java.io.FileNotFoundException; | |||
import java.io.InputStreamReader; | |||
import java.io.Reader; | |||
import java.util.Collection; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.concurrent.Callable; | |||
import java.util.concurrent.ExecutionException; | |||
import java.util.concurrent.ExecutorService; | |||
import java.util.concurrent.Executors; | |||
import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.TimeoutException; | |||
import java.util.concurrent.*; | |||
public class JavaCpdEngine extends CpdEngine { | |||
@@ -201,25 +193,12 @@ public class JavaCpdEngine extends CpdEngine { | |||
if (duplications == null || Iterables.isEmpty(duplications)) { | |||
return; | |||
} | |||
Set<Integer> duplicatedLines = new HashSet<Integer>(); | |||
int duplicatedBlocks = computeBlockAndLineCount(duplications, duplicatedLines); | |||
Map<Integer, Integer> duplicationByLine = new HashMap<Integer, Integer>(); | |||
for (int i = 1; i <= inputFile.lines(); i++) { | |||
duplicationByLine.put(i, duplicatedLines.contains(i) ? 1 : 0); | |||
} | |||
saveMeasures(context, inputFile, duplicatedLines, duplicatedBlocks, duplicationByLine); | |||
computeBlockAndLineCount(context, inputFile, duplications); | |||
saveDuplications(context, inputFile, duplications); | |||
} | |||
private static void saveMeasures(org.sonar.api.batch.sensor.SensorContext context, InputFile inputFile, Set<Integer> duplicatedLines, int duplicatedBlocks, | |||
Map<Integer, Integer> duplicationByLine) { | |||
((DefaultMeasure<String>) context.<String>newMeasure() | |||
.forMetric(CoreMetrics.DUPLICATION_LINES_DATA) | |||
.onFile(inputFile) | |||
.withValue(KeyValueFormat.format(duplicationByLine))) | |||
.setFromCore() | |||
.save(); | |||
private static void saveMeasures(org.sonar.api.batch.sensor.SensorContext context, InputFile inputFile, int duplicatedLines, int duplicatedBlocks) { | |||
// Save | |||
((DefaultMeasure<Integer>) context.<Integer>newMeasure() | |||
.forMetric(CoreMetrics.DUPLICATED_FILES) | |||
@@ -230,7 +209,7 @@ public class JavaCpdEngine extends CpdEngine { | |||
((DefaultMeasure<Integer>) context.<Integer>newMeasure() | |||
.forMetric(CoreMetrics.DUPLICATED_LINES) | |||
.onFile(inputFile) | |||
.withValue(duplicatedLines.size())) | |||
.withValue(duplicatedLines)) | |||
.setFromCore() | |||
.save(); | |||
((DefaultMeasure<Integer>) context.<Integer>newMeasure() | |||
@@ -268,8 +247,9 @@ public class JavaCpdEngine extends CpdEngine { | |||
} | |||
} | |||
private static int computeBlockAndLineCount(Iterable<CloneGroup> duplications, Set<Integer> duplicatedLines) { | |||
private static void computeBlockAndLineCount(org.sonar.api.batch.sensor.SensorContext context, InputFile inputFile, Iterable<CloneGroup> duplications) { | |||
int duplicatedBlocks = 0; | |||
Set<Integer> duplicatedLines = new HashSet<>(); | |||
for (CloneGroup clone : duplications) { | |||
ClonePart origin = clone.getOriginPart(); | |||
for (ClonePart part : clone.getCloneParts()) { | |||
@@ -281,7 +261,7 @@ public class JavaCpdEngine extends CpdEngine { | |||
} | |||
} | |||
} | |||
return duplicatedBlocks; | |||
saveMeasures(context, inputFile, duplicatedLines.size(), duplicatedBlocks); | |||
} | |||
} |
@@ -72,7 +72,6 @@ public class DefaultIndex extends SonarIndex { | |||
CoreMetrics.FILE_TANGLES, | |||
// Computed by CpdSensor | |||
CoreMetrics.DUPLICATIONS_DATA, | |||
CoreMetrics.DUPLICATION_LINES_DATA, | |||
CoreMetrics.DUPLICATED_FILES, | |||
CoreMetrics.DUPLICATED_LINES, | |||
CoreMetrics.DUPLICATED_BLOCKS, | |||
@@ -175,6 +174,7 @@ public class DefaultIndex extends SonarIndex { | |||
entry.getValue().clear(); | |||
it.remove(); | |||
} | |||
} | |||
// Keep only inter module dependencies | |||
@@ -226,7 +226,7 @@ public class DefaultIndex extends SonarIndex { | |||
if (metric == null) { | |||
throw new SonarException("Unknown metric: " + measure.getMetricKey()); | |||
} | |||
if (!isViewResource(resource) && !measure.isFromCore() && INTERNAL_METRICS.contains(metric)) { | |||
if (!measure.isFromCore() && INTERNAL_METRICS.contains(metric)) { | |||
LOG.debug("Metric " + metric.key() + " is an internal metric computed by SonarQube. Provided value is ignored."); | |||
return measure; | |||
} | |||
@@ -238,14 +238,6 @@ public class DefaultIndex extends SonarIndex { | |||
return measure; | |||
} | |||
/** | |||
* Views plugin creates copy of technical projects and should be allowed to copy all measures even internal ones | |||
*/ | |||
private boolean isViewResource(Resource resource) { | |||
boolean isTechnicalProject = Scopes.FILE.equals(resource.getScope()) && Qualifiers.PROJECT.equals(resource.getQualifier()); | |||
return isTechnicalProject || ResourceUtils.isView(resource) || ResourceUtils.isSubview(resource); | |||
} | |||
// | |||
// | |||
// |
@@ -19,17 +19,15 @@ | |||
*/ | |||
package org.sonar.batch.mediumtest; | |||
import com.google.common.collect.LinkedHashMultimap; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Multimap; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.fs.InputDir; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextPointer; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.api.batch.fs.*; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.sensor.dependency.internal.DefaultDependency; | |||
import org.sonar.api.batch.sensor.duplication.Duplication; | |||
@@ -41,6 +39,7 @@ import org.sonar.api.measures.Measure; | |||
import org.sonar.batch.dependency.DependencyCache; | |||
import org.sonar.batch.duplication.DuplicationCache; | |||
import org.sonar.batch.index.Cache.Entry; | |||
import org.sonar.batch.index.ResourceCache; | |||
import org.sonar.batch.issue.IssueCache; | |||
import org.sonar.batch.protocol.output.*; | |||
import org.sonar.batch.protocol.output.BatchReport.Component; | |||
@@ -66,7 +65,7 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver { | |||
private static final Logger LOG = LoggerFactory.getLogger(TaskResult.class); | |||
private List<Issue> issues = new ArrayList<>(); | |||
private List<org.sonar.api.batch.sensor.measure.Measure> measures = new ArrayList<>(); | |||
private Multimap<String, org.sonar.api.batch.sensor.measure.Measure> measures = LinkedHashMultimap.create(); | |||
private Map<String, List<Duplication>> duplications = new HashMap<>(); | |||
private Map<String, InputFile> inputFiles = new HashMap<>(); | |||
private Map<String, Component> reportComponents = new HashMap<>(); | |||
@@ -115,19 +114,24 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver { | |||
} | |||
private void storeMeasures(ProjectScanContainer container) { | |||
InputPathCache inputFileCache = container.getComponentByType(InputPathCache.class); | |||
ResourceCache resourceCache = container.getComponentByType(ResourceCache.class); | |||
for (Entry<Measure> measureEntry : container.getComponentByType(MeasureCache.class).entries()) { | |||
String componentKey = measureEntry.key()[0].toString(); | |||
InputFile file = inputFileCache.getFile(StringUtils.substringBeforeLast(componentKey, ":"), StringUtils.substringAfterLast(componentKey, ":")); | |||
InputPath path = resourceCache.get(componentKey).inputPath(); | |||
Measure oldMeasure = measureEntry.value(); | |||
DefaultMeasure<Serializable> newMeasure = new DefaultMeasure<>().forMetric(oldMeasure.getMetric()); | |||
if (file != null) { | |||
newMeasure.onFile(file); | |||
if (path != null) { | |||
if (path instanceof InputFile) { | |||
newMeasure.onFile((InputFile) path); | |||
} else { | |||
// Ignore measure on directories since this will disappear in target architecture | |||
continue; | |||
} | |||
} else { | |||
newMeasure.onProject(); | |||
} | |||
newMeasure.withValue(oldMeasure.value()); | |||
measures.add(newMeasure); | |||
measures.put(componentKey, newMeasure); | |||
} | |||
} | |||
@@ -164,8 +168,12 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver { | |||
return issues; | |||
} | |||
public List<org.sonar.api.batch.sensor.measure.Measure> measures() { | |||
return measures; | |||
public Collection<org.sonar.api.batch.sensor.measure.Measure> allMeasures() { | |||
return measures.values(); | |||
} | |||
public Collection<org.sonar.api.batch.sensor.measure.Measure> measures(String componentKey) { | |||
return measures.get(componentKey); | |||
} | |||
public Collection<InputFile> inputFiles() { |
@@ -1,159 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.phases; | |||
import org.sonar.api.batch.SensorContext; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.batch.events.BatchStepEvent; | |||
import org.sonar.batch.events.EventBus; | |||
import org.sonar.batch.index.DefaultIndex; | |||
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader; | |||
import org.sonar.batch.issue.tracking.LocalIssueTracking; | |||
import org.sonar.batch.report.ReportPublisher; | |||
import org.sonar.batch.rule.QProfileVerifier; | |||
import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; | |||
import org.sonar.batch.scan.filesystem.FileSystemLogger; | |||
import org.sonar.batch.scan.report.IssuesReports; | |||
public final class DatabaseLessPhaseExecutor implements PhaseExecutor { | |||
private final EventBus eventBus; | |||
private final Phases phases; | |||
private final InitializersExecutor initializersExecutor; | |||
private final PostJobsExecutor postJobsExecutor; | |||
private final SensorsExecutor sensorsExecutor; | |||
private final SensorContext sensorContext; | |||
private final DefaultIndex index; | |||
private final ProjectInitializer pi; | |||
private final FileSystemLogger fsLogger; | |||
private final DefaultModuleFileSystem fs; | |||
private final QProfileVerifier profileVerifier; | |||
private final IssueExclusionsLoader issueExclusionsLoader; | |||
private final IssuesReports issuesReport; | |||
private final LocalIssueTracking localIssueTracking; | |||
private final ReportPublisher reportPublisher; | |||
public DatabaseLessPhaseExecutor(Phases phases, InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, | |||
SensorContext sensorContext, DefaultIndex index, | |||
EventBus eventBus, ProjectInitializer pi, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier, | |||
IssueExclusionsLoader issueExclusionsLoader, LocalIssueTracking localIssueTracking, ReportPublisher reportPublisher) { | |||
this.phases = phases; | |||
this.initializersExecutor = initializersExecutor; | |||
this.postJobsExecutor = postJobsExecutor; | |||
this.sensorsExecutor = sensorsExecutor; | |||
this.sensorContext = sensorContext; | |||
this.index = index; | |||
this.eventBus = eventBus; | |||
this.pi = pi; | |||
this.fsLogger = fsLogger; | |||
this.issuesReport = jsonReport; | |||
this.fs = fs; | |||
this.profileVerifier = profileVerifier; | |||
this.issueExclusionsLoader = issueExclusionsLoader; | |||
this.localIssueTracking = localIssueTracking; | |||
this.reportPublisher = reportPublisher; | |||
} | |||
/** | |||
* Executed on each module | |||
*/ | |||
@Override | |||
public void execute(Project module) { | |||
pi.execute(module); | |||
eventBus.fireEvent(new ProjectAnalysisEvent(module, true)); | |||
executeInitializersPhase(); | |||
if (phases.isEnabled(Phases.Phase.SENSOR)) { | |||
// Index and lock the filesystem | |||
indexFs(); | |||
// Log detected languages and their profiles after FS is indexed and languages detected | |||
profileVerifier.execute(); | |||
// Initialize issue exclusions | |||
initIssueExclusions(); | |||
sensorsExecutor.execute(sensorContext); | |||
} | |||
if (module.isRoot()) { | |||
localIssueTracking(); | |||
issuesReport(); | |||
publishReportJob(); | |||
if (phases.isEnabled(Phases.Phase.POSTJOB)) { | |||
postJobsExecutor.execute(sensorContext); | |||
} | |||
} | |||
cleanMemory(); | |||
eventBus.fireEvent(new ProjectAnalysisEvent(module, false)); | |||
} | |||
private void publishReportJob() { | |||
String stepName = "Publish report"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
this.reportPublisher.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void localIssueTracking() { | |||
String stepName = "Local Issue Tracking"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
localIssueTracking.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void issuesReport() { | |||
String stepName = "Issues Reports"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
issuesReport.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void initIssueExclusions() { | |||
String stepName = "Init issue exclusions"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
issueExclusionsLoader.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void indexFs() { | |||
String stepName = "Index filesystem and store sources"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
fs.index(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void executeInitializersPhase() { | |||
if (phases.isEnabled(Phases.Phase.INIT)) { | |||
initializersExecutor.execute(); | |||
fsLogger.log(); | |||
} | |||
} | |||
private void cleanMemory() { | |||
String cleanMemory = "Clean memory"; | |||
eventBus.fireEvent(new BatchStepEvent(cleanMemory, true)); | |||
index.clear(); | |||
eventBus.fireEvent(new BatchStepEvent(cleanMemory, false)); | |||
} | |||
} |
@@ -1,188 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.phases; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.SensorContext; | |||
import org.sonar.api.database.DatabaseSession; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.batch.bootstrap.DefaultAnalysisMode; | |||
import org.sonar.batch.events.BatchStepEvent; | |||
import org.sonar.batch.events.EventBus; | |||
import org.sonar.batch.index.DefaultIndex; | |||
import org.sonar.batch.index.ResourcePersister; | |||
import org.sonar.batch.index.ScanPersister; | |||
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader; | |||
import org.sonar.batch.report.ReportPublisher; | |||
import org.sonar.batch.rule.QProfileVerifier; | |||
import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; | |||
import org.sonar.batch.scan.filesystem.FileSystemLogger; | |||
import org.sonar.batch.scan.report.IssuesReports; | |||
import java.util.Arrays; | |||
public final class DatabaseModePhaseExecutor implements PhaseExecutor { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseModePhaseExecutor.class); | |||
private final EventBus eventBus; | |||
private final Phases phases; | |||
private final DecoratorsExecutor decoratorsExecutor; | |||
private final PostJobsExecutor postJobsExecutor; | |||
private final InitializersExecutor initializersExecutor; | |||
private final SensorsExecutor sensorsExecutor; | |||
private final ReportPublisher reportPublisher; | |||
private final SensorContext sensorContext; | |||
private final DefaultIndex index; | |||
private final ProjectInitializer pi; | |||
private final ScanPersister[] persisters; | |||
private final FileSystemLogger fsLogger; | |||
private final IssuesReports jsonReport; | |||
private final DefaultModuleFileSystem fs; | |||
private final QProfileVerifier profileVerifier; | |||
private final IssueExclusionsLoader issueExclusionsLoader; | |||
private final DefaultAnalysisMode analysisMode; | |||
private final DatabaseSession session; | |||
private final ResourcePersister resourcePersister; | |||
public DatabaseModePhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor, | |||
InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, | |||
SensorContext sensorContext, DefaultIndex index, | |||
EventBus eventBus, ReportPublisher reportPublisher, ProjectInitializer pi, | |||
ScanPersister[] persisters, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier, | |||
IssueExclusionsLoader issueExclusionsLoader, DefaultAnalysisMode analysisMode, DatabaseSession session, ResourcePersister resourcePersister) { | |||
this.phases = phases; | |||
this.decoratorsExecutor = decoratorsExecutor; | |||
this.postJobsExecutor = postJobsExecutor; | |||
this.initializersExecutor = initializersExecutor; | |||
this.sensorsExecutor = sensorsExecutor; | |||
this.sensorContext = sensorContext; | |||
this.index = index; | |||
this.eventBus = eventBus; | |||
this.reportPublisher = reportPublisher; | |||
this.pi = pi; | |||
this.persisters = persisters; | |||
this.fsLogger = fsLogger; | |||
this.jsonReport = jsonReport; | |||
this.fs = fs; | |||
this.profileVerifier = profileVerifier; | |||
this.issueExclusionsLoader = issueExclusionsLoader; | |||
this.analysisMode = analysisMode; | |||
this.session = session; | |||
this.resourcePersister = resourcePersister; | |||
} | |||
/** | |||
* Executed on each module | |||
*/ | |||
@Override | |||
public void execute(Project module) { | |||
pi.execute(module); | |||
eventBus.fireEvent(new ProjectAnalysisEvent(module, true)); | |||
executeInitializersPhase(); | |||
if (phases.isEnabled(Phases.Phase.SENSOR)) { | |||
// Index and lock the filesystem | |||
indexFs(); | |||
// Log detected languages and their profiles after FS is indexed and languages detected | |||
profileVerifier.execute(); | |||
// Initialize issue exclusions | |||
initIssueExclusions(); | |||
// SONAR-2965 In case the sensor takes too much time we close the session to not face a timeout | |||
session.commitAndClose(); | |||
sensorsExecutor.execute(sensorContext); | |||
} | |||
// Special case for views. | |||
resourcePersister.persist(); | |||
if (phases.isEnabled(Phases.Phase.DECORATOR)) { | |||
decoratorsExecutor.execute(); | |||
} | |||
if (module.isRoot()) { | |||
jsonReport.execute(); | |||
executePersisters(); | |||
publishReportJob(); | |||
if (phases.isEnabled(Phases.Phase.POSTJOB)) { | |||
postJobsExecutor.execute(sensorContext); | |||
} | |||
} | |||
cleanMemory(); | |||
eventBus.fireEvent(new ProjectAnalysisEvent(module, false)); | |||
} | |||
private void initIssueExclusions() { | |||
String stepName = "Init issue exclusions"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
issueExclusionsLoader.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void indexFs() { | |||
String stepName = "Index filesystem and store sources"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
fs.index(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void executePersisters() { | |||
if (!analysisMode.isPreview()) { | |||
LOGGER.info("Store results in database"); | |||
eventBus.fireEvent(new PersistersPhaseEvent(Arrays.asList(persisters), true)); | |||
for (ScanPersister persister : persisters) { | |||
LOGGER.debug("Execute {}", persister.getClass().getName()); | |||
eventBus.fireEvent(new PersisterExecutionEvent(persister, true)); | |||
persister.persist(); | |||
eventBus.fireEvent(new PersisterExecutionEvent(persister, false)); | |||
} | |||
eventBus.fireEvent(new PersistersPhaseEvent(Arrays.asList(persisters), false)); | |||
} | |||
} | |||
private void publishReportJob() { | |||
String stepName = "Publish report"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
this.reportPublisher.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void executeInitializersPhase() { | |||
if (phases.isEnabled(Phases.Phase.INIT)) { | |||
initializersExecutor.execute(); | |||
fsLogger.log(); | |||
} | |||
} | |||
private void cleanMemory() { | |||
String cleanMemory = "Clean memory"; | |||
eventBus.fireEvent(new BatchStepEvent(cleanMemory, true)); | |||
index.clear(); | |||
eventBus.fireEvent(new BatchStepEvent(cleanMemory, false)); | |||
} | |||
} |
@@ -0,0 +1,64 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.phases; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.batch.bootstrap.DefaultAnalysisMode; | |||
import org.sonar.batch.events.EventBus; | |||
import org.sonar.batch.index.ScanPersister; | |||
import java.util.Arrays; | |||
public class PersistersExecutor implements BatchComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(PersistersExecutor.class); | |||
private final ScanPersister[] persisters; | |||
private final DefaultAnalysisMode analysisMode; | |||
private final EventBus eventBus; | |||
public PersistersExecutor(DefaultAnalysisMode analysisMode, EventBus eventBus, ScanPersister[] persisters) { | |||
this.analysisMode = analysisMode; | |||
this.eventBus = eventBus; | |||
this.persisters = persisters; | |||
} | |||
public PersistersExecutor(DefaultAnalysisMode analysisMode, EventBus eventBus) { | |||
this(analysisMode, eventBus, new ScanPersister[0]); | |||
} | |||
public void execute() { | |||
if (analysisMode.isDb()) { | |||
LOG.info("Store results in database"); | |||
eventBus.fireEvent(new PersistersPhaseEvent(Arrays.asList(persisters), true)); | |||
for (ScanPersister persister : persisters) { | |||
LOG.debug("Execute {}", persister.getClass().getName()); | |||
eventBus.fireEvent(new PersisterExecutionEvent(persister, true)); | |||
persister.persist(); | |||
eventBus.fireEvent(new PersisterExecutionEvent(persister, false)); | |||
} | |||
eventBus.fireEvent(new PersistersPhaseEvent(Arrays.asList(persisters), false)); | |||
} | |||
} | |||
} |
@@ -19,11 +19,149 @@ | |||
*/ | |||
package org.sonar.batch.phases; | |||
import org.sonar.api.batch.SensorContext; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.batch.bootstrap.DefaultAnalysisMode; | |||
import org.sonar.batch.events.BatchStepEvent; | |||
import org.sonar.batch.events.EventBus; | |||
import org.sonar.batch.index.DefaultIndex; | |||
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader; | |||
import org.sonar.batch.issue.tracking.LocalIssueTracking; | |||
import org.sonar.batch.report.ReportPublisher; | |||
import org.sonar.batch.rule.QProfileVerifier; | |||
import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; | |||
import org.sonar.batch.scan.filesystem.FileSystemLogger; | |||
import org.sonar.batch.scan.report.IssuesReports; | |||
public final class PhaseExecutor { | |||
private final EventBus eventBus; | |||
private final DecoratorsExecutor decoratorsExecutor; | |||
private final PostJobsExecutor postJobsExecutor; | |||
private final InitializersExecutor initializersExecutor; | |||
private final SensorsExecutor sensorsExecutor; | |||
private final ReportPublisher reportPublisher; | |||
private final SensorContext sensorContext; | |||
private final DefaultIndex index; | |||
private final ProjectInitializer pi; | |||
private final PersistersExecutor persistersExecutor; | |||
private final FileSystemLogger fsLogger; | |||
private final DefaultModuleFileSystem fs; | |||
private final QProfileVerifier profileVerifier; | |||
private final IssueExclusionsLoader issueExclusionsLoader; | |||
private final IssuesReports issuesReport; | |||
private final DefaultAnalysisMode analysisMode; | |||
private final LocalIssueTracking localIssueTracking; | |||
public PhaseExecutor(DecoratorsExecutor decoratorsExecutor, | |||
InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, | |||
SensorContext sensorContext, DefaultIndex index, | |||
EventBus eventBus, ReportPublisher reportPublisher, ProjectInitializer pi, | |||
PersistersExecutor persistersExecutor, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier, | |||
IssueExclusionsLoader issueExclusionsLoader, DefaultAnalysisMode analysisMode, LocalIssueTracking localIssueTracking) { | |||
this.decoratorsExecutor = decoratorsExecutor; | |||
this.postJobsExecutor = postJobsExecutor; | |||
this.initializersExecutor = initializersExecutor; | |||
this.sensorsExecutor = sensorsExecutor; | |||
this.sensorContext = sensorContext; | |||
this.index = index; | |||
this.eventBus = eventBus; | |||
this.reportPublisher = reportPublisher; | |||
this.pi = pi; | |||
this.persistersExecutor = persistersExecutor; | |||
this.fsLogger = fsLogger; | |||
this.issuesReport = jsonReport; | |||
this.fs = fs; | |||
this.profileVerifier = profileVerifier; | |||
this.issueExclusionsLoader = issueExclusionsLoader; | |||
this.analysisMode = analysisMode; | |||
this.localIssueTracking = localIssueTracking; | |||
} | |||
public interface PhaseExecutor { | |||
/** | |||
* Executed on each module | |||
*/ | |||
public void execute(Project module); | |||
public void execute(Project module) { | |||
pi.execute(module); | |||
eventBus.fireEvent(new ProjectAnalysisEvent(module, true)); | |||
executeInitializersPhase(); | |||
// Index and lock the filesystem | |||
indexFs(); | |||
// Log detected languages and their profiles after FS is indexed and languages detected | |||
profileVerifier.execute(); | |||
// Initialize issue exclusions | |||
initIssueExclusions(); | |||
sensorsExecutor.execute(sensorContext); | |||
decoratorsExecutor.execute(); | |||
if (module.isRoot()) { | |||
if (analysisMode.isPreview()) { | |||
localIssueTracking(); | |||
} | |||
issuesReport(); | |||
if (!analysisMode.isPreview()) { | |||
persistersExecutor.execute(); | |||
} | |||
publishReportJob(); | |||
postJobsExecutor.execute(sensorContext); | |||
} | |||
cleanMemory(); | |||
eventBus.fireEvent(new ProjectAnalysisEvent(module, false)); | |||
} | |||
private void publishReportJob() { | |||
String stepName = "Publish report"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
this.reportPublisher.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void localIssueTracking() { | |||
String stepName = "Local Issue Tracking"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
localIssueTracking.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void issuesReport() { | |||
String stepName = "Issues Reports"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
issuesReport.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void initIssueExclusions() { | |||
String stepName = "Init issue exclusions"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
issueExclusionsLoader.execute(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void indexFs() { | |||
String stepName = "Index filesystem and store sources"; | |||
eventBus.fireEvent(new BatchStepEvent(stepName, true)); | |||
fs.index(); | |||
eventBus.fireEvent(new BatchStepEvent(stepName, false)); | |||
} | |||
private void executeInitializersPhase() { | |||
initializersExecutor.execute(); | |||
fsLogger.log(); | |||
} | |||
private void cleanMemory() { | |||
String cleanMemory = "Clean memory"; | |||
eventBus.fireEvent(new BatchStepEvent(cleanMemory, true)); | |||
index.clear(); | |||
eventBus.fireEvent(new BatchStepEvent(cleanMemory, false)); | |||
} | |||
} |
@@ -22,20 +22,15 @@ package org.sonar.batch.profiling; | |||
import com.google.common.collect.Maps; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.batch.phases.Phases; | |||
import org.sonar.batch.phases.Phases.Phase; | |||
import javax.annotation.Nullable; | |||
import java.util.HashMap; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.*; | |||
import java.util.Map.Entry; | |||
import java.util.Properties; | |||
public class ModuleProfiling extends AbstractTimeProfiling { | |||
private Map<Phases.Phase, PhaseProfiling> profilingPerPhase = new HashMap<Phases.Phase, PhaseProfiling>(); | |||
private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<Phase, PhaseProfiling>(); | |||
private Map<String, ItemProfiling> profilingPerBatchStep = new LinkedHashMap<String, ItemProfiling>(); | |||
private final Project module; | |||
@@ -81,7 +76,7 @@ public class ModuleProfiling extends AbstractTimeProfiling { | |||
println(" * " + batchStep.getKey() + " execution time: ", percent, batchStep.getValue()); | |||
} | |||
// Breakdown per phase | |||
for (Phase phase : Phases.Phase.values()) { | |||
for (Phase phase : Phase.values()) { | |||
if (profilingPerPhase.containsKey(phase) && getProfilingPerPhase(phase).hasItems()) { | |||
println(""); | |||
println(" * " + phase + " execution time breakdown: ", getProfilingPerPhase(phase)); | |||
@@ -92,7 +87,7 @@ public class ModuleProfiling extends AbstractTimeProfiling { | |||
public void merge(ModuleProfiling other) { | |||
super.add(other); | |||
for (Entry<Phases.Phase, PhaseProfiling> entry : other.profilingPerPhase.entrySet()) { | |||
for (Entry<Phase, PhaseProfiling> entry : other.profilingPerPhase.entrySet()) { | |||
if (!this.profilingPerPhase.containsKey(entry.getKey())) { | |||
this.addPhaseProfiling(entry.getKey()); | |||
} |
@@ -17,45 +17,21 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.phases; | |||
package org.sonar.batch.profiling; | |||
import com.google.common.collect.Sets; | |||
public enum Phase { | |||
import java.util.Arrays; | |||
import java.util.Set; | |||
INIT("Initializers"), SENSOR("Sensors"), DECORATOR("Decorators"), PERSISTER("Persisters"), POSTJOB("Post-Jobs"); | |||
/** | |||
* Used by views | |||
*/ | |||
public class Phases { | |||
public enum Phase { | |||
INIT("Initializers"), SENSOR("Sensors"), DECORATOR("Decorators"), PERSISTER("Persisters"), POSTJOB("Post-Jobs"); | |||
private final String label; | |||
private Phase(String label) { | |||
this.label = label; | |||
} | |||
private final String label; | |||
@Override | |||
public String toString() { | |||
return label; | |||
} | |||
private Phase(String label) { | |||
this.label = label; | |||
} | |||
private final Set<Phase> enabled = Sets.newHashSet(); | |||
public Phases enable(Phase... phases) { | |||
enabled.addAll(Arrays.asList(phases)); | |||
return this; | |||
} | |||
public boolean isEnabled(Phase phase) { | |||
return enabled.contains(phase); | |||
@Override | |||
public String toString() { | |||
return label; | |||
} | |||
public boolean isFullyEnabled() { | |||
return enabled.containsAll(Arrays.asList(Phase.values())); | |||
} | |||
} |
@@ -20,7 +20,6 @@ | |||
package org.sonar.batch.profiling; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.batch.phases.Phases.Phase; | |||
import java.util.HashMap; | |||
import java.util.Map; |
@@ -26,21 +26,12 @@ import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.Decorator; | |||
import org.sonar.api.batch.events.DecoratorExecutionHandler; | |||
import org.sonar.api.batch.events.DecoratorsPhaseHandler; | |||
import org.sonar.api.batch.events.InitializerExecutionHandler; | |||
import org.sonar.api.batch.events.InitializersPhaseHandler; | |||
import org.sonar.api.batch.events.PostJobExecutionHandler; | |||
import org.sonar.api.batch.events.PostJobsPhaseHandler; | |||
import org.sonar.api.batch.events.ProjectAnalysisHandler; | |||
import org.sonar.api.batch.events.SensorExecutionHandler; | |||
import org.sonar.api.batch.events.SensorsPhaseHandler; | |||
import org.sonar.api.batch.events.*; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.TimeUtils; | |||
import org.sonar.batch.bootstrap.BootstrapProperties; | |||
import org.sonar.batch.events.BatchStepHandler; | |||
import org.sonar.batch.phases.Phases; | |||
import org.sonar.batch.phases.event.PersisterExecutionHandler; | |||
import org.sonar.batch.phases.event.PersistersPhaseHandler; | |||
import org.sonar.batch.util.BatchUtils; | |||
@@ -49,11 +40,7 @@ import javax.annotation.Nullable; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.util.HashMap; | |||
import java.util.IdentityHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Properties; | |||
import java.util.*; | |||
import static org.sonar.batch.profiling.AbstractTimeProfiling.sortByDescendingTotalTime; | |||
import static org.sonar.batch.profiling.AbstractTimeProfiling.truncate; | |||
@@ -161,15 +148,15 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx | |||
@Override | |||
public void onSensorsPhase(SensorsPhaseEvent event) { | |||
if (event.isStart()) { | |||
currentModuleProfiling.addPhaseProfiling(Phases.Phase.SENSOR); | |||
currentModuleProfiling.addPhaseProfiling(Phase.SENSOR); | |||
} else { | |||
currentModuleProfiling.getProfilingPerPhase(Phases.Phase.SENSOR).stop(); | |||
currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).stop(); | |||
} | |||
} | |||
@Override | |||
public void onSensorExecution(SensorExecutionEvent event) { | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.SENSOR); | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR); | |||
if (event.isStart()) { | |||
profiling.newItemProfiling(event.getSensor()); | |||
} else { | |||
@@ -180,15 +167,15 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx | |||
@Override | |||
public void onPersistersPhase(PersistersPhaseEvent event) { | |||
if (event.isStart()) { | |||
currentModuleProfiling.addPhaseProfiling(Phases.Phase.PERSISTER); | |||
currentModuleProfiling.addPhaseProfiling(Phase.PERSISTER); | |||
} else { | |||
currentModuleProfiling.getProfilingPerPhase(Phases.Phase.PERSISTER).stop(); | |||
currentModuleProfiling.getProfilingPerPhase(Phase.PERSISTER).stop(); | |||
} | |||
} | |||
@Override | |||
public void onPersisterExecution(PersisterExecutionEvent event) { | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.PERSISTER); | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phase.PERSISTER); | |||
if (event.isStart()) { | |||
profiling.newItemProfiling(event.getPersister()); | |||
} else { | |||
@@ -198,7 +185,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx | |||
@Override | |||
public void onDecoratorExecution(DecoratorExecutionEvent event) { | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.DECORATOR); | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR); | |||
if (event.isStart()) { | |||
if (profiling.getProfilingPerItem(event.getDecorator()) == null) { | |||
profiling.newItemProfiling(event.getDecorator()); | |||
@@ -212,28 +199,28 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx | |||
@Override | |||
public void onDecoratorsPhase(DecoratorsPhaseEvent event) { | |||
if (event.isStart()) { | |||
currentModuleProfiling.addPhaseProfiling(Phases.Phase.DECORATOR); | |||
currentModuleProfiling.addPhaseProfiling(Phase.DECORATOR); | |||
} else { | |||
for (Decorator decorator : decoratorsProfiler.getDurations().keySet()) { | |||
currentModuleProfiling.getProfilingPerPhase(Phases.Phase.DECORATOR) | |||
currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR) | |||
.getProfilingPerItem(decorator).setTotalTime(decoratorsProfiler.getDurations().get(decorator)); | |||
} | |||
currentModuleProfiling.getProfilingPerPhase(Phases.Phase.DECORATOR).stop(); | |||
currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR).stop(); | |||
} | |||
} | |||
@Override | |||
public void onPostJobsPhase(PostJobsPhaseEvent event) { | |||
if (event.isStart()) { | |||
currentModuleProfiling.addPhaseProfiling(Phases.Phase.POSTJOB); | |||
currentModuleProfiling.addPhaseProfiling(Phase.POSTJOB); | |||
} else { | |||
currentModuleProfiling.getProfilingPerPhase(Phases.Phase.POSTJOB).stop(); | |||
currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB).stop(); | |||
} | |||
} | |||
@Override | |||
public void onPostJobExecution(PostJobExecutionEvent event) { | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.POSTJOB); | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB); | |||
if (event.isStart()) { | |||
profiling.newItemProfiling(event.getPostJob()); | |||
} else { | |||
@@ -244,15 +231,15 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx | |||
@Override | |||
public void onInitializersPhase(InitializersPhaseEvent event) { | |||
if (event.isStart()) { | |||
currentModuleProfiling.addPhaseProfiling(Phases.Phase.INIT); | |||
currentModuleProfiling.addPhaseProfiling(Phase.INIT); | |||
} else { | |||
currentModuleProfiling.getProfilingPerPhase(Phases.Phase.INIT).stop(); | |||
currentModuleProfiling.getProfilingPerPhase(Phase.INIT).stop(); | |||
} | |||
} | |||
@Override | |||
public void onInitializerExecution(InitializerExecutionEvent event) { | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.INIT); | |||
PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phase.INIT); | |||
if (event.isStart()) { | |||
profiling.newItemProfiling(event.getInitializer()); | |||
} else { |
@@ -112,7 +112,7 @@ public class ComponentsPublisher implements ReportPublisherStep { | |||
} | |||
private void writeEvents(BatchResource batchResource, Builder builder) { | |||
if (isRealProjectOrModule(batchResource.resource())) { | |||
if (ResourceUtils.isProject(batchResource.resource())) { | |||
for (Event event : eventCache.getEvents(batchResource.batchId())) { | |||
builder.addEvent(event); | |||
} | |||
@@ -120,7 +120,7 @@ public class ComponentsPublisher implements ReportPublisherStep { | |||
} | |||
private void writeVersion(Resource r, BatchReport.Component.Builder builder) { | |||
if (isRealProjectOrModule(r)) { | |||
if (ResourceUtils.isProject(r)) { | |||
ProjectDefinition def = getProjectDefinition(reactor, r.getKey()); | |||
String version = getVersion(def); | |||
builder.setVersion(version); | |||
@@ -133,7 +133,7 @@ public class ComponentsPublisher implements ReportPublisherStep { | |||
} | |||
private void writeLinks(Resource r, BatchReport.Component.Builder builder) { | |||
if (isRealProjectOrModule(r)) { | |||
if (ResourceUtils.isProject(r)) { | |||
ProjectDefinition def = getProjectDefinition(reactor, r.getKey()); | |||
ComponentLink.Builder linkBuilder = ComponentLink.newBuilder(); | |||
@@ -145,11 +145,6 @@ public class ComponentsPublisher implements ReportPublisherStep { | |||
} | |||
} | |||
// Exclude views | |||
private static boolean isRealProjectOrModule(Resource r) { | |||
return ResourceUtils.isProject(r) && !ResourceUtils.isView(r) && !ResourceUtils.isSubview(r); | |||
} | |||
private ProjectDefinition getProjectDefinition(ProjectReactor reactor, String keyWithBranch) { | |||
for (ProjectDefinition p : reactor.getProjects()) { | |||
if (keyWithBranch.equals(p.getKeyWithBranch())) { | |||
@@ -191,10 +186,6 @@ public class ComponentsPublisher implements ReportPublisherStep { | |||
return Constants.ComponentType.MODULE; | |||
} else if (ResourceUtils.isRootProject(r)) { | |||
return Constants.ComponentType.PROJECT; | |||
} else if (ResourceUtils.isView(r)) { | |||
return Constants.ComponentType.VIEW; | |||
} else if (ResourceUtils.isSubview(r)) { | |||
return Constants.ComponentType.SUBVIEW; | |||
} | |||
throw new IllegalArgumentException("Unknown resource type: " + r); | |||
} |
@@ -101,18 +101,15 @@ public class ModuleScanContainer extends ComponentContainer { | |||
ModuleSettings moduleSettings = getComponentByType(ModuleSettings.class); | |||
module.setSettings(moduleSettings); | |||
if (analysisMode.isDb()) { | |||
add(DatabaseModePhaseExecutor.class); | |||
} else { | |||
add(RuleFinderCompatibility.class, | |||
DatabaseLessPhaseExecutor.class); | |||
} | |||
add( | |||
PhaseExecutor.class, | |||
RuleFinderCompatibility.class, | |||
EventBus.class, | |||
PhasesTimeProfiler.class, | |||
PostJobsExecutor.class, | |||
DecoratorsExecutor.class, | |||
SensorsExecutor.class, | |||
PersistersExecutor.class, | |||
InitializersExecutor.class, | |||
ProjectInitializer.class, | |||
moduleDefinition.getContainerExtensions(), | |||
@@ -180,8 +177,7 @@ public class ModuleScanContainer extends ComponentContainer { | |||
} | |||
private void addDataBaseComponents() { | |||
add(DecoratorsExecutor.class, | |||
add( | |||
// Quality Gate | |||
QualityGateVerifier.class, | |||
GenerateQualityGateEvents.class, | |||
@@ -226,8 +222,7 @@ public class ModuleScanContainer extends ComponentContainer { | |||
@Override | |||
protected void doAfterStart() { | |||
DefaultIndex index = getComponentByType(DefaultIndex.class); | |||
index.setCurrentProject(module, | |||
getComponentByType(ModuleIssues.class)); | |||
index.setCurrentProject(module, getComponentByType(ModuleIssues.class)); | |||
getComponentByType(PhaseExecutor.class).execute(module); | |||
@@ -153,7 +153,6 @@ public class ProjectScanContainer extends ComponentContainer { | |||
TestPlanBuilder.class, | |||
TestableBuilder.class, | |||
ScanGraph.create(), | |||
GraphPersister.class, | |||
// lang | |||
Languages.class, | |||
@@ -197,6 +196,7 @@ public class ProjectScanContainer extends ComponentContainer { | |||
add( | |||
ResourcePersister.class, | |||
ResourceKeyMigration.class, | |||
GraphPersister.class, | |||
// Users | |||
DefaultUserFinder.class, |
@@ -25,7 +25,6 @@ import org.sonar.api.task.Task; | |||
import org.sonar.api.task.TaskDefinition; | |||
import org.sonar.batch.DefaultProjectTree; | |||
import org.sonar.batch.bootstrap.TaskContainer; | |||
import org.sonar.batch.phases.Phases; | |||
public class ScanTask implements Task { | |||
public static final TaskDefinition DEFINITION = TaskDefinition.builder() | |||
@@ -48,7 +47,6 @@ public class ScanTask implements Task { | |||
// Add components specific to project scan (views will use different ones) | |||
void scan(ComponentContainer scanContainer) { | |||
scanContainer.add( | |||
new Phases().enable(Phases.Phase.values()), | |||
DefaultProjectTree.class, | |||
ProjectExclusions.class, | |||
ProjectReactorValidator.class, |
@@ -23,19 +23,12 @@ import com.google.common.base.Joiner; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.Properties; | |||
import org.sonar.api.Property; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.*; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.InstantiationStrategy; | |||
import org.sonar.api.batch.bootstrap.ProjectReactor; | |||
import org.sonar.api.batch.scm.ScmProvider; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.batch.phases.Phases; | |||
import javax.annotation.Nullable; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
@@ -62,38 +55,26 @@ public final class ScmConfiguration implements BatchComponent, Startable { | |||
private final ProjectReactor projectReactor; | |||
private final Settings settings; | |||
private final Map<String, ScmProvider> providerPerKey = new LinkedHashMap<String, ScmProvider>(); | |||
private final Phases phases; | |||
private final AnalysisMode analysisMode; | |||
private ScmProvider provider; | |||
public ScmConfiguration(ProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings, @Nullable Phases phases, ScmProvider... providers) { | |||
public ScmConfiguration(ProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings, ScmProvider... providers) { | |||
this.projectReactor = projectReactor; | |||
this.analysisMode = analysisMode; | |||
this.settings = settings; | |||
this.phases = phases; | |||
for (ScmProvider scmProvider : providers) { | |||
providerPerKey.put(scmProvider.key(), scmProvider); | |||
} | |||
} | |||
// Scan 2 | |||
public ScmConfiguration(ProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings, ScmProvider... providers) { | |||
this(projectReactor, analysisMode, settings, null, providers); | |||
} | |||
public ScmConfiguration(ProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings, Phases phases) { | |||
this(projectReactor, analysisMode, settings, phases, new ScmProvider[0]); | |||
} | |||
// Scan2 | |||
public ScmConfiguration(ProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings) { | |||
this(projectReactor, analysisMode, settings, null, new ScmProvider[0]); | |||
this(projectReactor, analysisMode, settings, new ScmProvider[0]); | |||
} | |||
@Override | |||
public void start() { | |||
if (analysisMode.isPreview() || (phases != null && !phases.isEnabled(Phases.Phase.SENSOR))) { | |||
if (analysisMode.isPreview()) { | |||
return; | |||
} | |||
if (isDisabled()) { |
@@ -19,8 +19,6 @@ | |||
*/ | |||
package org.sonar.batch.cpd; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
@@ -31,6 +29,7 @@ import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.duplication.NewDuplication; | |||
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.batch.sensor.measure.Measure; | |||
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; | |||
import org.sonar.api.measures.CoreMetrics; | |||
@@ -92,7 +91,6 @@ public class JavaCpdEngineTest { | |||
verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.DUPLICATED_FILES).onFile(inputFile).withValue(1)); | |||
verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.DUPLICATED_BLOCKS).onFile(inputFile).withValue(1)); | |||
verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.DUPLICATED_LINES).onFile(inputFile).withValue(3)); | |||
verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.DUPLICATION_LINES_DATA).onFile(inputFile).withValue("1=0;2=1;3=1;4=1;5=0")); | |||
verify(storage).store(new DefaultDuplication() | |||
.originBlock(inputFile, 2, 4) |
@@ -90,22 +90,22 @@ public class CoverageMediumTest { | |||
assertThat(result.coverageFor(file, 2).getItCoveredConditions()).isEqualTo(0); | |||
assertThat(result.coverageFor(file, 2).getOverallCoveredConditions()).isEqualTo(0); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
assertThat(result.allMeasures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.LINES_TO_COVER) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue(2)); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
assertThat(result.allMeasures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.UNCOVERED_LINES) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue(0)); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
assertThat(result.allMeasures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.CONDITIONS_TO_COVER) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue(2)); | |||
assertThat(result.measures()).contains(new DefaultMeasure<String>() | |||
assertThat(result.allMeasures()).contains(new DefaultMeasure<String>() | |||
.forMetric(CoreMetrics.COVERED_CONDITIONS_BY_LINE) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue("2=1")); |
@@ -31,8 +31,6 @@ import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.sensor.duplication.Duplication; | |||
import org.sonar.api.batch.sensor.measure.Measure; | |||
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.batch.mediumtest.BatchMediumTester; | |||
import org.sonar.batch.mediumtest.TaskResult; | |||
import org.sonar.xoo.XooPlugin; | |||
@@ -42,6 +40,7 @@ import java.io.IOException; | |||
import java.util.List; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Assertions.tuple; | |||
public class CpdMediumTest { | |||
@@ -103,8 +102,8 @@ public class CpdMediumTest { | |||
assertThat(result.inputFiles()).hasSize(2); | |||
// 5 measures per file + quality profile measure | |||
assertThat(result.measures()).hasSize(11); | |||
assertThat(result.measures("com.foo.project:src/sample1.xoo")).extracting("metric.key", "value").contains(tuple("duplicated_blocks", 1), tuple("duplicated_files", 1), | |||
tuple("duplicated_lines", 17)); | |||
InputFile inputFile1 = result.inputFile("src/sample1.xoo"); | |||
InputFile inputFile2 = result.inputFile("src/sample2.xoo"); | |||
@@ -156,7 +155,7 @@ public class CpdMediumTest { | |||
.start(); | |||
Measure duplicatedBlocks = null; | |||
for (Measure m : result.measures()) { | |||
for (Measure m : result.allMeasures()) { | |||
if (m.metric().key().equals("duplicated_blocks")) { | |||
duplicatedBlocks = m; | |||
} | |||
@@ -189,8 +188,8 @@ public class CpdMediumTest { | |||
.build()) | |||
.start(); | |||
// 5 measures per file + QP measure | |||
assertThat(result.measures()).hasSize(6); | |||
assertThat(result.measures("com.foo.project:src/sample.xoo")).extracting("metric.key", "value").contains(tuple("duplicated_blocks", 2), tuple("duplicated_files", 1), | |||
tuple("duplicated_lines", 4)); | |||
InputFile inputFile = result.inputFile("src/sample.xoo"); | |||
// One clone group | |||
@@ -204,11 +203,6 @@ public class CpdMediumTest { | |||
assertThat(cloneGroup.duplicates()).hasSize(1); | |||
assertThat(cloneGroup.duplicates().get(0).startLine()).isEqualTo(5); | |||
assertThat(cloneGroup.duplicates().get(0).length()).isEqualTo(2); | |||
assertThat(result.measures()).contains(new DefaultMeasure<String>() | |||
.forMetric(CoreMetrics.DUPLICATION_LINES_DATA) | |||
.onFile(inputFile) | |||
.withValue("1=1;2=1;3=0;4=0;5=1;6=1;7=0")); | |||
} | |||
} |
@@ -36,6 +36,7 @@ import java.io.File; | |||
import java.io.IOException; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Assertions.tuple; | |||
public class MeasuresMediumTest { | |||
@@ -65,7 +66,7 @@ public class MeasuresMediumTest { | |||
.newScanTask(new File(projectDir, "sonar-project.properties")) | |||
.start(); | |||
assertThat(result.measures()).hasSize(13); | |||
assertThat(result.allMeasures()).hasSize(20); | |||
} | |||
@Test | |||
@@ -92,9 +93,9 @@ public class MeasuresMediumTest { | |||
.build()) | |||
.start(); | |||
assertThat(result.measures()).hasSize(2); | |||
assertThat(result.allMeasures()).hasSize(4); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
assertThat(result.allMeasures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.LINES) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue(2)); | |||
@@ -127,23 +128,8 @@ public class MeasuresMediumTest { | |||
.build()) | |||
.start(); | |||
// QP + 2 x lines + 1 x ncloc+ 1 x lines_to_cover | |||
assertThat(result.measures()).hasSize(5); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.LINES) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue(3)); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.LINES) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.other")) | |||
.withValue(3)); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.NCLOC) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.other")) | |||
.withValue(2)); | |||
assertThat(result.measures("com.foo.project:src/sample.xoo")).extracting("metric.key", "value").contains(tuple("lines", 3)); | |||
assertThat(result.measures("com.foo.project:src/sample.other")).extracting("metric.key", "value").contains(tuple("lines", 3), tuple("ncloc", 2)); | |||
} | |||
} |
@@ -291,7 +291,7 @@ public class ScmMediumTest { | |||
.build()) | |||
.start(); | |||
assertThat(result.measures()).hasSize(2); | |||
assertThat(result.allMeasures()).extracting("metric.key").containsOnly("lines", "quality_profiles"); | |||
} | |||
} |
@@ -1,55 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.phases; | |||
import org.junit.Test; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
public class PhasesTest { | |||
@Test | |||
public void no_phase_should_be_enabled_by_default() { | |||
Phases phases = new Phases(); | |||
assertThat(phases.isEnabled(Phases.Phase.DECORATOR)).isFalse(); | |||
} | |||
@Test | |||
public void phase_should_be_enabled() { | |||
Phases phases = new Phases(); | |||
phases.enable(Phases.Phase.SENSOR, Phases.Phase.DECORATOR); | |||
assertThat(phases.isEnabled(Phases.Phase.DECORATOR)).isTrue(); | |||
assertThat(phases.isEnabled(Phases.Phase.SENSOR)).isTrue(); | |||
assertThat(phases.isEnabled(Phases.Phase.POSTJOB)).isFalse(); | |||
assertThat(phases.isFullyEnabled()).isFalse(); | |||
} | |||
@Test | |||
public void all_phases_should_be_enabled() { | |||
Phases phases = new Phases(); | |||
phases.enable(Phases.Phase.values()); | |||
assertThat(phases.isEnabled(Phases.Phase.INIT)).isTrue(); | |||
assertThat(phases.isEnabled(Phases.Phase.DECORATOR)).isTrue(); | |||
assertThat(phases.isEnabled(Phases.Phase.SENSOR)).isTrue(); | |||
assertThat(phases.isEnabled(Phases.Phase.POSTJOB)).isTrue(); | |||
assertThat(phases.isFullyEnabled()).isTrue(); | |||
} | |||
} |
@@ -25,23 +25,10 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.Decorator; | |||
import org.sonar.api.batch.DecoratorContext; | |||
import org.sonar.api.batch.Initializer; | |||
import org.sonar.api.batch.PostJob; | |||
import org.sonar.api.batch.Sensor; | |||
import org.sonar.api.batch.SensorContext; | |||
import org.sonar.api.batch.events.DecoratorExecutionHandler; | |||
import org.sonar.api.batch.events.DecoratorsPhaseHandler; | |||
import org.sonar.api.batch.events.InitializerExecutionHandler; | |||
import org.sonar.api.batch.events.InitializersPhaseHandler; | |||
import org.sonar.api.batch.events.PostJobExecutionHandler; | |||
import org.sonar.api.batch.events.PostJobsPhaseHandler; | |||
import org.sonar.api.batch.events.ProjectAnalysisHandler; | |||
import org.sonar.api.batch.*; | |||
import org.sonar.api.batch.events.*; | |||
import org.sonar.api.batch.events.ProjectAnalysisHandler.ProjectAnalysisEvent; | |||
import org.sonar.api.batch.events.SensorExecutionHandler; | |||
import org.sonar.api.batch.events.SensorExecutionHandler.SensorExecutionEvent; | |||
import org.sonar.api.batch.events.SensorsPhaseHandler; | |||
import org.sonar.api.batch.events.SensorsPhaseHandler.SensorsPhaseEvent; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.resources.Resource; | |||
@@ -49,7 +36,6 @@ import org.sonar.api.utils.System2; | |||
import org.sonar.batch.bootstrap.BootstrapProperties; | |||
import org.sonar.batch.events.BatchStepEvent; | |||
import org.sonar.batch.index.ScanPersister; | |||
import org.sonar.batch.phases.Phases.Phase; | |||
import org.sonar.batch.phases.event.PersisterExecutionHandler; | |||
import org.sonar.batch.phases.event.PersistersPhaseHandler; | |||
@@ -21,17 +21,8 @@ package org.sonar.batch.scan; | |||
import org.junit.Test; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.bootstrap.ProjectReactor; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.platform.ComponentContainer; | |||
import org.sonar.batch.ProjectConfigurator; | |||
import org.sonar.batch.bootstrap.TaskContainer; | |||
import org.sonar.batch.phases.Phases; | |||
import org.sonar.core.resource.ResourceDao; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
public class ScanTaskTest { | |||
@Test | |||
@@ -40,16 +31,4 @@ public class ScanTaskTest { | |||
assertThat(ScanTask.DEFINITION.key()).isEqualTo(CoreProperties.SCAN_TASK); | |||
} | |||
@Test | |||
public void should_enable_all_phases() { | |||
ScanTask task = new ScanTask(mock(TaskContainer.class)); | |||
ComponentContainer projectScanContainer = new ComponentContainer(); | |||
projectScanContainer.add(mock(ProjectConfigurator.class), new ProjectReactor(ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, "foo")), | |||
mock(Settings.class), | |||
mock(ResourceDao.class)); | |||
task.scan(projectScanContainer); | |||
Phases phases = projectScanContainer.getComponentByType(Phases.class); | |||
assertThat(phases.isFullyEnabled()).isTrue(); | |||
} | |||
} |
@@ -1391,25 +1391,6 @@ public final class CoreMetrics { | |||
.setDeleteHistoricalData(true) | |||
.create(); | |||
/** | |||
* @since 4.5 used by dev cockpit. | |||
*/ | |||
@Beta | |||
public static final String DUPLICATION_LINES_DATA_KEY = "duplication_lines_data"; | |||
/** | |||
* Information about duplication in file. | |||
* Key-value pairs, where key - is a number of line, and value - is an indicator of whether line is duplicated somewhere (1) or not (0). | |||
* | |||
* @see org.sonar.api.measures.FileLinesContext | |||
* @since 4.5 used by dev cockpit | |||
*/ | |||
@Beta | |||
public static final Metric<String> DUPLICATION_LINES_DATA = new Metric.Builder(DUPLICATION_LINES_DATA_KEY, "duplication_lines_data", Metric.ValueType.DATA) | |||
.setHidden(true) | |||
.setDomain(DOMAIN_DUPLICATION) | |||
.create(); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// | |||
// CODING RULES |