treasure-data/embulk-input-zendesk

View on GitHub

Showing 49 of 49 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if (taskReport.has(ZendeskConstants.Field.END_TIME)) {
                final Long endTime = taskReport.get(Long.class, ZendeskConstants.Field.END_TIME);
                if (endTime != null) {
                    final OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(endTime), ZoneOffset.UTC);
                    configDiff.set(ZendeskConstants.Field.END_TIME,
src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java on lines 269..276

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method addRecordToImporter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public TaskReport addRecordToImporter(final int taskIndex, final RecordImporter recordImporter)
    {
        final TaskReport taskReport = CONFIG_MAPPER_FACTORY.newTaskReport();
        String startTime = getStartTime();

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 createSampleData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private List<List<Object>> createSampleData(JsonNode jsonNode, String targetJsonName, List<String> unifiedFieldNames)
    {
        final List<List<Object>> samples = new ArrayList<>();
        Iterator<JsonNode> records = ZendeskUtils.getListRecords(jsonNode, targetJsonName);
        while (records.hasNext()) {
Severity: Minor
Found in src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java - About 1 hr to fix

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 addRecordToImporter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public TaskReport addRecordToImporter(final int taskIndex, final RecordImporter recordImporter)
    {
        final TaskReport taskReport = CONFIG_MAPPER_FACTORY.newTaskReport();
        String startTime = getStartTime();

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if (jsonNode.has("links") && !ZendeskUtils.isNull(jsonNode.get("links"))
                    && jsonNode.get("links").has("next") && !ZendeskUtils.isNull(jsonNode.get("links").get("next"))) {
                path = task.getLoginUrl() + jsonNode.get("links").get("next");
                return true;
            }
    src/main/java/org/embulk/input/zendesk/stream/paginator/sunshine/SunshineSpliterator.java on lines 59..63

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if (jsonNode.has("links") && !ZendeskUtils.isNull(jsonNode.get("links"))
                    && jsonNode.get("links").has("next") && !ZendeskUtils.isNull(jsonNode.get("links").get("next"))) {
                path = task.getLoginUrl() + jsonNode.get("links").get("next");
                return true;
            }
    src/main/java/org/embulk/input/zendesk/stream/paginator/sunshine/CustomObjectSpliterator.java on lines 35..39

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method storeStartTimeForConfigDiff has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private void storeStartTimeForConfigDiff(final TaskReport taskReport, final long initStartTime, final long resultEndTime)
        {
            if (task.getIncremental()) {
                long nextStartTime;
                long now = Instant.now().getEpochSecond();

    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 sendGetRequest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private String sendGetRequest(final String url, final PluginTask task)
            throws ZendeskException
        {
            try {
                final HttpClient client = createHttpClient();

    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 getDataFromPath has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public JsonNode getDataFromPath(final String path, final int page, final boolean isPreview, final long startTime)
        {
            Preconditions.checkArgument(isPreview, "IsPreview should be true to use this method");
    
    

    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 storeStartTimeForConfigDiff has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private void storeStartTimeForConfigDiff(final TaskReport taskReport, final long initStartTime, final long resultEndTime)
        {
            if (task.getIncremental()) {
                long nextStartTime;
                long now = Instant.now().getEpochSecond();

    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 sendGetRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private String sendGetRequest(final String url, final PluginTask task)
            throws ZendeskException
        {
            try {
                final HttpClient client = createHttpClient();

      Method isContinue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          protected boolean isContinue(final JsonNode jsonNode, final Consumer<? super JsonNode> action)
          {
              final Iterator<JsonNode> iterator = ZendeskUtils.getListRecords(jsonNode, task.getTarget().getJsonName());
      
      

      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 validateCredentials has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private void validateCredentials(PluginTask task)
          {
              switch (task.getAuthenticationMethod()) {
                  case OAUTH:
                      if (!task.getAccessToken().isPresent()) {
      Severity: Minor
      Found in src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java - About 55 mins to fix

      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 tryAdvance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public boolean tryAdvance(final Consumer<? super JsonNode> action)
          {
              try {
                  final String result = zendeskRestClient.doGet(path, task, isPreview);

      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

      Avoid deeply nested control flow statements.
      Open

                              if (type.equals(Types.TIMESTAMP.getName())) {
                                  entry.remove("format");
                              }
      Severity: Major
      Found in src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java - About 45 mins to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            @JsonCreator
            public static Target fromString(final String value)
            {
                try {
                    return Target.valueOf(value.trim().toUpperCase());
        Severity: Minor
        Found in src/main/java/org/embulk/input/zendesk/models/Target.java and 1 other location - About 40 mins to fix
        src/main/java/org/embulk/input/zendesk/models/AuthenticationMethod.java on lines 12..22

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            @JsonCreator
            public static AuthenticationMethod fromString(final String value)
            {
                try {
                    return AuthenticationMethod.valueOf(value.trim().toUpperCase());
        src/main/java/org/embulk/input/zendesk/models/Target.java on lines 25..35

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if (data.get("count").asInt() > 0) {
                        data.get("docs").forEach(item -> {
                            if (item != null) {
                                recordImporter.addRecord(item);
                            }
        src/main/java/org/embulk/input/zendesk/services/ZendeskChatService.java on lines 203..209

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 48.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if (data.get("count").asInt() > 0) {
                    data.get("docs").forEach(item -> {
                        if (item != null) {
                            arrayNode.add(item);
                        }
        src/main/java/org/embulk/input/zendesk/services/ZendeskChatService.java on lines 132..138

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 48.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    case BASIC:
                        if (!task.getUsername().isPresent() || !task.getPassword().isPresent()) {
                            throw new ConfigException(String.format("username and password are required for authentication method '%s'",
                                task.getAuthenticationMethod().name().toLowerCase()));
                        }
        Severity: Minor
        Found in src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java and 1 other location - About 35 mins to fix
        src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java on lines 508..513

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 46.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language