jnidzwetzki/bitfinex-v2-wss-api-java

View on GitHub

Showing 81 of 126 total issues

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

        return "BitfinexSubmittedOrder [" +
                "orderId=" + orderId +
                ", createdTimestamp=" + createdTimestamp +
                ", updatedTimestamp=" + updatedTimestamp +
                ", amount=" + amount +
src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/BitfinexApiKeyPermissions.java on lines 161..173

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

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

        return "BitfinexApiKeyPermissions [" +
                "orderReadPermission=" + orderReadPermission +
                ", orderWritePermission=" + orderWritePermission +
                ", accountReadPermission=" + accountReadPermission +
                ", accountWritePermission=" + accountWritePermission +
src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/BitfinexSubmittedOrder.java on lines 213..225

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

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

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/currency/BitfinexFundingCurrency.java on lines 74..89

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

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

/*******************************************************************************
 *
 *    Copyright (C) 2015-2018 Jan Kristof Nidzwetzki
 *  
 *    Licensed under the Apache License, Version 2.0 (the "License");
src/main/java/com/github/jnidzwetzki/bitfinex/v2/command/SubscribeTradesCommand.java on lines 1..50

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

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

    @Override
    public boolean equals(final Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
src/main/java/com/github/jnidzwetzki/bitfinex/v2/symbol/BitfinexFundingSymbol.java on lines 64..79

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

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

/*******************************************************************************
 *
 *    Copyright (C) 2015-2018 Jan Kristof Nidzwetzki
 *  
 *    Licensed under the Apache License, Version 2.0 (the "License");
src/main/java/com/github/jnidzwetzki/bitfinex/v2/command/SubscribeTickerCommand.java on lines 1..50

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

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 String toString() {
        return "BitfinexTick [bid=" + bid + ", bidSize=" + bidSize + ", ask=" + ask + ", askSize=" + askSize
                + ", dailyChange=" + dailyChange + ", dailyChangePerc=" + dailyChangePerc + ", lastPrice=" + lastPrice
                + ", volume=" + volume + ", high=" + high + ", low=" + low + "]";
src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/BitfinexPosition.java on lines 117..123

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

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 String toString() {
        return "BitfinexPosition [currencyPair=" + currencyPair + ", status=" + status + ", amount=" + amount + ", basePrice=" + basePrice
                + ", marginFunding=" + marginFunding + ", marginFundingType=" + marginFundingType + ", profitLoss=" + profitLoss
                + ", profitLossPercent=" + profitLossPercent + ", priceLiquidation=" + priceLiquidation + ", leverage=" + leverage
src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/BitfinexTick.java on lines 130..135

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

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

    @Override
    public void sendCommand(BitfinexCommand command) {
        if (command instanceof SetConnectionFeaturesCommand) {
            clients.values().forEach(c -> c.sendCommand(command));
            return;

    Method getCommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public String getCommand(final BitfinexWebsocketClient client) throws BitfinexCommandException {
            final JSONObject orderJson = new JSONObject();
            orderJson.put("type", bitfinexOrder.getOrderType().getBifinexString());
            orderJson.put("symbol", bitfinexOrder.getCurrencyPair().toBitfinexString());

      Method jsonToBitfinexApiKeyPermissions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private BitfinexApiKeyPermissions jsonToBitfinexApiKeyPermissions(final JSONObject jsonObject) {
              final JSONObject caps = jsonObject.getJSONObject("caps");
              JSONObject orders = caps.getJSONObject("orders");
              boolean orderReadPermission = orders.getInt("read") == 1;
              boolean orderWritePermission = orders.getInt("write") == 1;

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

            private void auditPrivateSequence(final long nextPrivateSequnceNumber) {
                if(privateSequence == -1) {
                    privateSequence = nextPrivateSequnceNumber;
                    return;
                }
        src/main/java/com/github/jnidzwetzki/bitfinex/v2/SequenceNumberAuditor.java on lines 118..134

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

        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

            private void auditPublicSequence(final long nextPublicSequnceNumber) {
                if(publicSequence == -1) {
                    publicSequence = nextPublicSequnceNumber;
                    return;
                }
        src/main/java/com/github/jnidzwetzki/bitfinex/v2/SequenceNumberAuditor.java on lines 141..157

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

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

            private BitfinexSubmittedOrder jsonToBitfinexSubmittedOrder(JSONArray array) {
                final JSONArray orderJson = array.optJSONArray(4);
                final long oid = orderJson.optLong(0, -1);
                final long gid = orderJson.optLong(1, -1);
                final long cid = orderJson.optLong(2, -1);

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

                  } finally {
                      Optional.ofNullable(authSuccessEventCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
                      Optional.ofNullable(authFailedCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
                      Optional.ofNullable(positionInitCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
                      Optional.ofNullable(walletsInitCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/SimpleBitfinexApiBroker.java on lines 339..345

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

          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

                  } finally {
                      Optional.ofNullable(authSuccessEventCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
                      Optional.ofNullable(authFailedCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
                      Optional.ofNullable(positionInitCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
                      Optional.ofNullable(walletsInitCallback).ifPresent(SimpleBitfinexApiBroker::safeClose);
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/SimpleBitfinexApiBroker.java on lines 471..477

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

          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 void close() {
                  try {
                      callbackRegistry.acceptConnectionStateChange(BitfinexConnectionStateEnum.DISCONNECTION_INIT);
                      for (BitfinexWebsocketClient bitfinexWebsocketClient : clients.values()) {
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/PooledBitfinexApiBroker.java on lines 96..108

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

          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 void connect() {
                  try {
                      callbackRegistry.acceptConnectionStateChange(BitfinexConnectionStateEnum.CONNECTION_INIT);
                      for (BitfinexWebsocketClient bitfinexWebsocketClient : clients.values()) {
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/PooledBitfinexApiBroker.java on lines 110..121

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

          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 3 locations. Consider refactoring.
          Open

              public WebsocketClientEndpoint(URI bitfinexURI, Consumer<String> onMessageConsumer,
                                             Consumer<CloseReason> onCloseConsumer,
                                             Consumer<Throwable> onErrorConsumer) {
                  this.endpointURI = bitfinexURI;
                  this.onMessageConsumer = onMessageConsumer;
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/BitfinexOrderBookEntry.java on lines 29..34
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/currency/BitfinexCurrencyPair.java on lines 215..222

          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

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

              private BitfinexCurrencyPair(final String pair1, final String pair2, 
                      final BitfinexCurrencyType currencyType, final double minimumOrderSize) {
                  
                  this.currency1 = pair1;
                  this.currency2 = pair2;
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/WebsocketClientEndpoint.java on lines 81..88
          src/main/java/com/github/jnidzwetzki/bitfinex/v2/entity/BitfinexOrderBookEntry.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 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