gojekfarm/beast

View on GitHub

Showing 31 of 31 total issues

AppConfig has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

public interface AppConfig extends Config {
    @Key("CONSUMER_POLL_TIMEOUT_MS")
    @DefaultValue("9223372036854775807")
    Long getConsumerPollTimeoutMs();

Severity: Minor
Found in src/main/java/com/gojek/beast/config/AppConfig.java - About 2 hrs to fix

    Method job has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public Status job() {
            offsetState.startTimer();
            try {
                Instant startTime = Instant.now();
    Severity: Minor
    Found in src/main/java/com/gojek/beast/worker/OffsetCommitWorker.java - About 2 hrs 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 job has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public Status job() {
            offsetState.startTimer();
            try {
                Instant startTime = Instant.now();
    Severity: Minor
    Found in src/main/java/com/gojek/beast/worker/OffsetCommitWorker.java - About 1 hr to fix

      Method getMappings has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private Map<String, Object> getMappings(DynamicMessage message, ColumnMapping columnMapping) {
              if (message == null || columnMapping == null || columnMapping.isEmpty()) {
                  return new HashMap<>();
              }
              if (message.getUnknownFields().asMap().size() > 0) {
      Severity: Minor
      Found in src/main/java/com/gojek/beast/converter/RowMapper.java - About 1 hr to fix

        Method push has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public Status push(Records records) {
                InsertAllResponse response = insertIntoBQ(records.getRecords());
                if (response.hasErrors()) {
                    //parse the error records
        Severity: Minor
        Found in src/main/java/com/gojek/beast/sink/bq/BqSink.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 main has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static void main(String[] args) throws IOException, InterruptedException {
                AppConfig appConfig = ConfigFactory.create(AppConfig.class, System.getenv());
                ProtoMappingConfig protoMappingConfig = ConfigFactory.create(ProtoMappingConfig.class, System.getenv());
                BackOffConfig backOffConfig = ConfigFactory.create(BackOffConfig.class, System.getenv());
                StencilConfig stencilConfig = ConfigFactory.create(StencilConfig.class, System.getenv());
        Severity: Minor
        Found in src/main/java/com/gojek/beast/launch/Main.java - About 1 hr to fix

          Method parseFields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              private ProtoField parseFields(ProtoField protoField, String protoSchema, Map<String, Descriptors.Descriptor> allDescriptors,
                                             Map<String, String> typeNameToPackageNameMap, int level) {
          
                  Descriptors.Descriptor currentProto = descriptorCache.fetch(allDescriptors, typeNameToPackageNameMap, protoSchema);
                  if (currentProto == null) {
          Severity: Minor
          Found in src/main/java/com/gojek/beast/protomapping/Parser.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 upsertDatasetAndTable has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void upsertDatasetAndTable(TableInfo tableInfo) {
                  Dataset dataSet = bigquery.getDataset(tableID.getDataset());
                  if (dataSet == null || !bigquery.getDataset(tableID.getDataset()).exists()) {
                      bigquery.create(
                              Dataset.newBuilder(tableID.getDataset())
          Severity: Minor
          Found in src/main/java/com/gojek/beast/sink/bq/BQClient.java - About 1 hr to fix

            Method push has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                public Status push(Records records) {
                    InsertAllResponse response = insertIntoBQ(records.getRecords());
                    if (response.hasErrors()) {
                        //parse the error records
            Severity: Minor
            Found in src/main/java/com/gojek/beast/sink/bq/BqSink.java - About 1 hr to fix

              Method pushToSink has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private Status pushToSink(Records poll) {
                      Status status;
                      try {
                          status = sink.push(poll);
                          statsClient.count("kafka.batch.records.size," + statsClient.getBqTags(), poll.getSize());
              Severity: Minor
              Found in src/main/java/com/gojek/beast/worker/BqQueueWorker.java - About 1 hr to fix

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

                    private void upsertDatasetAndTable(TableInfo tableInfo) {
                        Dataset dataSet = bigquery.getDataset(tableID.getDataset());
                        if (dataSet == null || !bigquery.getDataset(tableID.getDataset()).exists()) {
                            bigquery.create(
                                    Dataset.newBuilder(tableID.getDataset())
                Severity: Minor
                Found in src/main/java/com/gojek/beast/sink/bq/BQClient.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

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

                    @VisibleForTesting
                    public ProtoField(String name, String typeName, DescriptorProtos.FieldDescriptorProto.Type type, int index, List<ProtoField> fields) {
                        this.name = name;
                        this.typeName = typeName;
                        this.type = type;
                Severity: Minor
                Found in src/main/java/com/gojek/beast/models/ProtoField.java and 1 other location - About 55 mins to fix
                src/main/java/com/gojek/beast/models/ProtoField.java on lines 62..69

                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 64.

                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

                    @VisibleForTesting
                    public ProtoField(String name, String typeName, DescriptorProtos.FieldDescriptorProto.Type type, DescriptorProtos.FieldDescriptorProto.Label label, List<ProtoField> fields) {
                        this.name = name;
                        this.typeName = typeName;
                        this.type = type;
                Severity: Minor
                Found in src/main/java/com/gojek/beast/models/ProtoField.java and 1 other location - About 55 mins to fix
                src/main/java/com/gojek/beast/models/ProtoField.java on lines 77..84

                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 64.

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

                    public BQFilteredResponse parseResponse(final List<Record> records, final InsertAllResponse bqResponse) {
                        Map<Record, Set<BQRecordsErrorType>> filtered = parseErrors(records, bqResponse);
                        final List<Record> retryableRecords = new ArrayList<>();
                        final List<Record> unhandledRecords = new ArrayList<>();
                        final List<Record> oobRecords = new ArrayList<>();
                Severity: Minor
                Found in src/main/java/com/gojek/beast/sink/bq/handler/BQResponseParser.java - About 45 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 convert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public List<Record> convert(final Iterable<ConsumerRecord<byte[], byte[]>> messages) throws InvalidProtocolBufferException {
                        ArrayList<Record> validRecords = new ArrayList<>();
                        ArrayList<Record> invalidRecords = new ArrayList<>();
                        for (ConsumerRecord<byte[], byte[]> message : messages) {
                            if (message.value() == null) {
                Severity: Minor
                Found in src/main/java/com/gojek/beast/converter/ConsumerRecordConverter.java - About 45 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

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

                    @VisibleForTesting
                    public ProtoField(String name, String typeName, DescriptorProtos.FieldDescriptorProto.Type type, DescriptorProtos.FieldDescriptorProto.Label label) {
                        this.name = name;
                        this.typeName = typeName;
                        this.type = type;
                Severity: Minor
                Found in src/main/java/com/gojek/beast/models/ProtoField.java and 1 other location - About 45 mins to fix
                src/main/java/com/gojek/beast/models/ProtoField.java on lines 46..52

                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 53.

                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

                    @VisibleForTesting
                    public ProtoField(String name, DescriptorProtos.FieldDescriptorProto.Type type, DescriptorProtos.FieldDescriptorProto.Label label, List<ProtoField> fields) {
                        this.name = name;
                        this.type = type;
                        this.label = label;
                Severity: Minor
                Found in src/main/java/com/gojek/beast/models/ProtoField.java and 1 other location - About 45 mins to fix
                src/main/java/com/gojek/beast/models/ProtoField.java on lines 54..60

                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 53.

                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

                        try {
                            offered = recordQueue.offer(offsetmap, config.getTimeout(), config.getTimeoutUnit());
                            statsClient.gauge("queue.elements,name=" + config.getName(), recordQueue.size());
                        } catch (InterruptedException e) {
                            return new FailureStatus(e);
                Severity: Minor
                Found in src/main/java/com/gojek/beast/sink/OffsetMapQueueSink.java and 1 other location - About 40 mins to fix
                src/main/java/com/gojek/beast/sink/RecordsQueueSink.java on lines 25..30

                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

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

                        try {
                            offered = recordQueue.offer(messages, config.getTimeout(), config.getTimeoutUnit());
                            statsClient.gauge("queue.elements,name=" + config.getName(), recordQueue.size());
                        } catch (InterruptedException e) {
                            return new FailureStatus(e);
                Severity: Minor
                Found in src/main/java/com/gojek/beast/sink/RecordsQueueSink.java and 1 other location - About 40 mins to fix
                src/main/java/com/gojek/beast/sink/OffsetMapQueueSink.java on lines 29..34

                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

                    @Override
                    public Object getValue() {
                        if (fieldValue instanceof Collection<?>) {
                            List<DateTime> tsValues = new ArrayList<>();
                            for (Object field: (Collection<?>) fieldValue) {
                src/main/java/com/gojek/beast/converter/fields/StructField.java on lines 20..29

                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 49.

                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