Showing 10 of 17 total issues
Configuration
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
Open
@Introspected
public class Configuration {
private String apiKey;
private String uploadToken;
Method invoke
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void invoke(Configuration configuration)
{
Path configurationUploadPath = configuration.getUploadPath();
String apiKey = configuration.getApiKey();
String profile = configuration.getProfile();
Method downloadFile
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void downloadFile(Path downloadPath, String downloadFormat, String languageKey) throws IOException, InterruptedException
{
String endpointUrl = API_URL + "/cli/v1/download?downloadFormat=" + downloadFormat;
if (StringUtils.isNotEmpty(languageKey))
{
Method uploadFile
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void uploadFile(Path uploadPath, String languageKey, String uploadFormat, String uploadOptions) throws IOException, InterruptedException
{
int pseudoRandomNumber = (int) (random.nextDouble() * 1_000_000_000);
String boundary = "simplelocalize" + pseudoRandomNumber;
Map<Object, Object> formData = Maps.newHashMap();
Method load
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private Configuration load(Path configurationFilePath)
{
File file = new File(URLDecoder.decode(String.valueOf(configurationFilePath.toFile()), StandardCharsets.UTF_8));
Constructor yamlTargetClass = new Constructor(Configuration.class);
Yaml yaml = new Yaml(yamlTargetClass);
Method getMatchingFilesToUpload
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static List<FileToUpload> getMatchingFilesToUpload(Path uploadPathWithTemplateKey, String templateKey) throws IOException
{
List<FileToUpload> output = Lists.newArrayList();
File file = uploadPathWithTemplateKey.toFile();
File parentDirectoryFile = file.getParentFile();
Method unzipFiles
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static void unzipFiles(String zipFilePath, String destinationPath) throws IOException
{
byte[] buffer = new byte[1024];
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFilePath)))
{
Method invoke
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public void invoke(Configuration configuration)
{
Path configurationUploadPath = configuration.getUploadPath();
String apiKey = configuration.getApiKey();
String profile = configuration.getProfile();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method upload
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
@Option(names = {"--apiKey"}, description = "Project API Key") String apiKey,
@Option(names = {"--uploadPath"}, description = "Path to file with translation or translation keys to upload. Use '{lang}' to define language key if you are uploading more than one file with translations.") Path uploadPath,
@Option(names = {"--uploadFormat"}, description = "Translations or keys format") String uploadFormat,
@Option(names = {"--languageKey"}, description = "(Optional) Specify language key for single file upload") String languageKey,
@Option(names = {"--uploadOptions"}, description = "(Optional) Read more about 'uploadOptions' param at docs.simplelocalize.io") String uploadOptions
Method downloadFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public void downloadFile(Path downloadPath, String downloadFormat, String languageKey) throws IOException, InterruptedException
{
String endpointUrl = API_URL + "/cli/v1/download?downloadFormat=" + downloadFormat;
if (StringUtils.isNotEmpty(languageKey))
{
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"