Added PMD (as a linter test) to the projects. Botbuilder and Sample are skipped at present.
This commit is contained in:
Родитель
1a4a39ee24
Коммит
9555b05c8c
|
@ -16,3 +16,6 @@ insert_final_newline = true
|
|||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.xml]
|
||||
indent_size = 2
|
||||
|
|
|
@ -249,11 +249,8 @@
|
|||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,6 @@ import com.microsoft.rest.ServiceCallback;
|
|||
import com.microsoft.rest.ServiceFuture;
|
||||
import com.microsoft.rest.ServiceResponse;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.microsoft.bot.schema.models.ResourceResponse;
|
|||
import com.microsoft.rest.ServiceCallback;
|
||||
import com.microsoft.rest.ServiceFuture;
|
||||
import com.microsoft.rest.ServiceResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import rx.Observable;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package com.microsoft.bot.connector.authentication;
|
||||
|
||||
import com.microsoft.aad.adal4j.AuthenticationException;
|
||||
import com.microsoft.bot.connector.authentication.JwtTokenExtractor;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class CredentialProviderImpl extends BotCredentials implements Credential
|
|||
|
||||
@Override
|
||||
public CompletableFuture<String> getAppPasswordAsync(String appId) {
|
||||
return CompletableFuture.completedFuture((this.appId.equals(appId) ? this.appPassword : null));
|
||||
return CompletableFuture.completedFuture(this.appId.equals(appId) ? this.appPassword : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,6 @@ package com.microsoft.bot.connector.authentication;
|
|||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.microsoft.aad.adal4j.AuthenticationException;
|
||||
import com.microsoft.bot.connector.authentication.JwtTokenExtractor;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
|
@ -9,9 +9,6 @@ import com.auth0.jwt.exceptions.JWTVerificationException;
|
|||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.auth0.jwt.interfaces.Verification;
|
||||
import com.microsoft.aad.adal4j.AuthenticationException;
|
||||
import com.microsoft.bot.connector.authentication.ClaimsIdentity;
|
||||
import com.microsoft.bot.connector.authentication.ClaimsIdentityImpl;
|
||||
import com.microsoft.bot.connector.authentication.TokenValidationParameters;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -20,7 +17,6 @@ import java.util.Map;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
|
||||
package com.microsoft.bot.connector.authentication;
|
||||
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.microsoft.aad.adal4j.AuthenticationException;
|
||||
import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials;
|
||||
import com.microsoft.bot.connector.authentication.ClaimsIdentityImpl;
|
||||
import com.microsoft.bot.connector.authentication.EmulatorValidation;
|
||||
import com.microsoft.bot.schema.models.Activity;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
|
@ -31,11 +31,11 @@ public class MicrosoftAppCredentials implements ServiceClientCredentials {
|
|||
|
||||
private String currentToken = null;
|
||||
private long expiredTime = 0;
|
||||
private static final Object cacheSync = new Object();
|
||||
//private static final Object cacheSync = new Object();
|
||||
protected static final HashMap<String, OAuthResponse> cache = new HashMap<String, OAuthResponse>();
|
||||
|
||||
public final String OAuthEndpoint = AuthenticationConstants.ToChannelFromBotLoginUrl;
|
||||
public final String OAuthScope = AuthenticationConstants.ToChannelFromBotOAuthScope;
|
||||
public final String OAuthEndpoint = ToChannelFromBotLoginUrl;
|
||||
public final String OAuthScope = ToChannelFromBotOAuthScope;
|
||||
|
||||
|
||||
public String getTokenCacheKey() {
|
||||
|
@ -83,7 +83,7 @@ public class MicrosoftAppCredentials implements ServiceClientCredentials {
|
|||
}
|
||||
|
||||
|
||||
private boolean ShouldSetToken(String url) {
|
||||
protected boolean ShouldSetToken(String url) {
|
||||
if (isTrustedServiceUrl(url)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ public class MicrosoftAppCredentials implements ServiceClientCredentials {
|
|||
URL url = new URL(serviceUrl);
|
||||
trustServiceUrl(url, expirationTime);
|
||||
} catch (MalformedURLException e) {
|
||||
//TODO: What's missing here?
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
package com.microsoft.bot.connector.authentication;
|
||||
|
||||
import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
|
|
@ -84,7 +84,7 @@ public class OAuthClient extends ServiceClient {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.collect(joining("&", (uri.endsWith("?") ? uri : uri + "?"), ""));
|
||||
.collect(joining("&", uri.endsWith("?") ? uri : uri + "?", ""));
|
||||
return new URI(newUri);
|
||||
|
||||
|
||||
|
@ -177,8 +177,6 @@ public class OAuthClient extends ServiceClient {
|
|||
}
|
||||
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
String invocationId = null;
|
||||
|
||||
// Construct URL
|
||||
HashMap<String, String> qstrings = new HashMap<>();
|
||||
qstrings.put("userId", userId);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.microsoft.bot.connector.authentication;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -43,6 +42,6 @@ public class OAuthResponse
|
|||
}
|
||||
|
||||
@JsonAnySetter
|
||||
private HashMap<String, String> properties;
|
||||
public HashMap<String, String> properties;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.microsoft.azure.AzureClient;
|
|||
import com.microsoft.azure.AzureServiceClient;
|
||||
import com.microsoft.bot.connector.Attachments;
|
||||
import com.microsoft.bot.connector.ConnectorClient;
|
||||
import com.microsoft.bot.connector.Conversations;
|
||||
import com.microsoft.rest.credentials.ServiceClientCredentials;
|
||||
import com.microsoft.rest.RestClient;
|
||||
import com.microsoft.rest.retry.RetryStrategy;
|
||||
|
@ -19,7 +18,6 @@ import com.microsoft.rest.retry.RetryStrategy;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the ConnectorClientImpl class.
|
||||
|
|
|
@ -197,10 +197,8 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -4,8 +4,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.core.TreeNode;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.microsoft.bot.schema.ContactRelationUpdateActivity;
|
||||
import com.microsoft.bot.schema.TraceActivity;
|
||||
import com.microsoft.bot.schema.models.*;
|
||||
|
||||
|
||||
|
@ -79,7 +77,7 @@ public class ActivityImpl extends Activity {
|
|||
* @param value value of the operation
|
||||
* @param valueType valueType if helpful to identify the value schema (default is value.GetType().Name)
|
||||
* @param label descritive label of context. (Default is calling function name)
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public TraceActivity CreateTrace(String name) {
|
||||
return CreateTrace(name, null, null, null);
|
||||
|
@ -160,7 +158,7 @@ public class ActivityImpl extends Activity {
|
|||
reply.withType(ActivityTypes.TRACE);
|
||||
reply.withTimestamp(DateTime.now());
|
||||
reply.withAttachments(new ArrayList<Attachment>());
|
||||
reply.withEntities(new ArrayList<EntityImpl>());;
|
||||
reply.withEntities(new ArrayList<EntityImpl>());
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
@ -624,31 +622,31 @@ public class ActivityImpl extends Activity {
|
|||
|
||||
/**
|
||||
* Return an IMessageUpdateAcitvity if this is a MessageUpdate activity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
//public IMessageUpdateActivity AsMessageUpdateActivity() { return IsActivity(ActivityTypes.MessageUpdate) ? this : null; }
|
||||
|
||||
/**
|
||||
* Return an IMessageDeleteActivity if this is a MessageDelete activity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
//public IMessageDeleteActivity AsMessageDeleteActivity() { return IsActivity(ActivityTypes.MessageDelete) ? this : null; }
|
||||
|
||||
/**
|
||||
* Return an IMessageReactionActivity if this is a MessageReaction activity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
//public IMessageReactionActivity AsMessageReactionActivity() { return IsActivity(ActivityTypes.MessageReaction) ? this : null; }
|
||||
|
||||
/**
|
||||
* Return an ISuggestionActivity if this is a Suggestion activity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
//public ISuggestionActivity AsSuggestionActivity() { return IsActivity(ActivityTypes.Suggestion) ? this : null; }
|
||||
|
||||
/**
|
||||
* Return an ITraceActivity if this is a Trace activity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
//public ITraceActivity AsTraceActivity() { return IsActivity(ActivityTypes.Trace) ? this : null; }
|
||||
|
||||
|
@ -672,7 +670,7 @@ public class ActivityImpl extends Activity {
|
|||
return false;
|
||||
}
|
||||
|
||||
private Mention convertToMention(JsonNode node) {
|
||||
public Mention convertToMention(JsonNode node) {
|
||||
try {
|
||||
return ActivityImpl.mapper.treeToValue(node, Mention.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
|
@ -697,7 +695,7 @@ public class ActivityImpl extends Activity {
|
|||
|
||||
/**
|
||||
* Get channeldata as typed structure
|
||||
* @param activity
|
||||
* @param activity
|
||||
* @param TypeT type to use
|
||||
* @return typed Object or default(TypeT)
|
||||
*/
|
||||
|
@ -706,7 +704,7 @@ public class ActivityImpl extends Activity {
|
|||
return null;
|
||||
|
||||
if (classType.isInstance(this.channelData())) {
|
||||
return ((TypeT) this.channelData());
|
||||
return (TypeT) this.channelData();
|
||||
}
|
||||
JsonNode node = mapper.valueToTree(this.channelData());
|
||||
return mapper.treeToValue((TreeNode) node, classType);
|
||||
|
@ -714,10 +712,10 @@ public class ActivityImpl extends Activity {
|
|||
|
||||
/**
|
||||
* Get channeldata as typed structure
|
||||
* @param activity
|
||||
* @param activity
|
||||
* @param TypeT type to use
|
||||
* @param instance The resulting instance, if possible
|
||||
* @return
|
||||
* @return
|
||||
* {@code true} if value of {@linkalso Activity.ChannelData} was coerceable to {@code TypeT}, {@code false} otherwise.
|
||||
*/
|
||||
|
||||
|
@ -734,8 +732,8 @@ public class ActivityImpl extends Activity {
|
|||
return new ResultPair<Boolean, TypeT>(true, instance);
|
||||
}
|
||||
/**
|
||||
* Clone a activity
|
||||
* @param activity
|
||||
* Clone a activity
|
||||
* @param activity
|
||||
* @return new cloned activity
|
||||
*/
|
||||
public static Activity CloneActity(Activity activity) {
|
||||
|
|
|
@ -77,11 +77,11 @@ public class EntityImpl extends Entity {
|
|||
*/
|
||||
|
||||
/**
|
||||
* @param T
|
||||
* @param T
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
|
||||
public <T> T GetAs(Class<T> type) {
|
||||
|
@ -112,8 +112,8 @@ public class EntityImpl extends Entity {
|
|||
|
||||
/**
|
||||
* Set internal payload.
|
||||
* @param T
|
||||
* @param obj
|
||||
* @param T
|
||||
* @param obj
|
||||
*/
|
||||
|
||||
public <T> boolean SetAs(T obj) {
|
||||
|
@ -142,6 +142,5 @@ public class EntityImpl extends Entity {
|
|||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
package com.microsoft.bot.schema.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Channel account information for a conversation.
|
||||
|
@ -155,7 +152,7 @@ public class ConversationAccount {
|
|||
* while maintaining the object.
|
||||
*
|
||||
*/
|
||||
private HashMap<String, JsonNode> properties = new HashMap<String, JsonNode>();
|
||||
// private HashMap<String, JsonNode> properties = new HashMap<String, JsonNode>();
|
||||
|
||||
/**
|
||||
* Overflow properties.
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ConversationReferenceHelper {
|
|||
.withType(ActivityTypes.MESSAGE)
|
||||
.withId(UUID.randomUUID().toString())
|
||||
.withRecipient(new ChannelAccount()
|
||||
.withId((reference.bot().id()))
|
||||
.withId(reference.bot().id())
|
||||
.withName(reference.bot().name()))
|
||||
.withChannelId(reference.channelId())
|
||||
.withServiceUrl(reference.serviceUrl())
|
||||
|
|
|
@ -181,6 +181,16 @@
|
|||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<configuration>
|
||||
<analysisCache>true</analysisCache>
|
||||
<excludes>
|
||||
<exclude>**/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
@ -265,10 +275,8 @@
|
|||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -135,7 +135,6 @@ public abstract class BotAdapter {
|
|||
callback.accept(context);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
49
pom.xml
49
pom.xml
|
@ -4,18 +4,31 @@
|
|||
<groupId>com.microsoft.bot</groupId>
|
||||
<artifactId>bot-parent</artifactId>
|
||||
<version>4.0.0-a0</version>
|
||||
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
<name>Microsoft BotBuilder SDK Parent</name>
|
||||
<description>This package contains the parent module of Microsoft BotBuilder SDK.</description>
|
||||
<url>https://github.com/Microsoft/botbuilder-java</url>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>build</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<modules>
|
||||
<module>libraries/botbuilder-schema</module>
|
||||
<module>libraries/botbuilder</module>
|
||||
|
@ -66,7 +79,33 @@
|
|||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
<configuration>
|
||||
<printFailingErrors>true</printFailingErrors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -125,6 +125,16 @@
|
|||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<configuration>
|
||||
<analysisCache>true</analysisCache>
|
||||
<excludes>
|
||||
<exclude>**/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
Загрузка…
Ссылка в новой задаче