patrickfav/armadillo

View on GitHub

Showing 46 of 46 total issues

File ASecureSharedPreferencesTest.java has 503 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package at.favre.lib.armadillo;

import android.content.SharedPreferences;

import junit.framework.TestCase;

    ASecureSharedPreferencesTest has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @SuppressWarnings("deprecation")
    public abstract class ASecureSharedPreferencesTest {
        private static final String DEFAULT_PREF_NAME = "test-prefs";
        SharedPreferences preferences;
    
    

      File SecureSharedPreferences.java has 426 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package at.favre.lib.armadillo;
      
      import android.annotation.SuppressLint;
      import android.content.Context;
      import android.content.SharedPreferences;

        Builder has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

            public static final class Builder {
        
                private final SharedPreferences sharedPreferences;
                private final Context context;
                private final String prefName;
        Severity: Minor
        Found in armadillo/src/main/java/at/favre/lib/armadillo/Armadillo.java - About 3 hrs to fix

          SecureSharedPreferences has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          @SuppressWarnings( {"unused", "WeakerAccess", "UnusedReturnValue"})
          public final class SecureSharedPreferences implements ArmadilloSharedPreferences {
          
              private static final String PREFERENCES_SALT_KEY = "at.favre.lib.securepref.KEY_RANDOM";
              private static final String PASSWORD_VALIDATION_KEY = "at.favre.lib.securepref.PASSWORD_VALIDATION_KEY";

            Method testUpgradeToNewerProtocolVersion has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Test
                public void testUpgradeToNewerProtocolVersion() {
                    assumeFalse("test not supported on kitkat devices", isKitKatOrBelow());
            
                    // open new preference with old encryption config

              Method testChangePasswordAndKeyStretchingFunction has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Test
                  public void testChangePasswordAndKeyStretchingFunction() {
                      Set<String> testSet = new HashSet<>();
                      testSet.add("t1");
                      testSet.add("t2");

                Method benchmark has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    @Test
                    public void benchmark() {
                        List<AbstractBcrypt> contender = Arrays.asList(new FavreBcrypt(), new JBcrypt(), new BC());
                        prepareMap(contender);
                
                

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

                    private void testChangePassword(String name, char[] currentPassword, char[] newPassword, boolean enableCache) {
                        Set<String> testSet = new HashSet<>();
                        testSet.add("t1");
                        testSet.add("t2");
                        testSet.add("t3");

                  Method benchmark has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @Test
                      public void benchmark() {
                          List<AbstractBcrypt> contender = Arrays.asList(new FavreBcrypt(), new JBcrypt(), new BC());
                          prepareMap(contender);
                  
                  

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

                        private Cipher getCipher() {
                            Cipher cipher = cipherWrapper.get();
                            if (cipher == null) {
                                try {
                                    if (provider != null) {
                    armadillo/src/main/java/at/favre/lib/armadillo/AesGcmEncryption.java on lines 120..137

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

                    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

                        private Cipher getCipher() {
                            Cipher cipher = cipherWrapper.get();
                            if (cipher == null) {
                                try {
                                    if (provider != null) {
                    armadillo/src/main/java/at/favre/lib/armadillo/AesCbcEncryption.java on lines 198..215

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

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

                            public ArmadilloSharedPreferences build() {
                                if (fingerprint == null) {
                                    throw new IllegalArgumentException("No encryption fingerprint is set - see encryptionFingerprint() methods");
                                }
                    
                    
                    Severity: Minor
                    Found in armadillo/src/main/java/at/favre/lib/armadillo/Armadillo.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

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

                        @Override
                        public String getString(String key, String defaultValue) {
                            final String keyHash = encryptionProtocol.deriveContentKey(key);
                            final String encryptedValue = sharedPreferences.getString(keyHash, null);
                            if (encryptedValue == null) {
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 180..193
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 195..208
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 210..223

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

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

                        @Override
                        public int getInt(String key, int defaultValue) {
                            final String keyHash = encryptionProtocol.deriveContentKey(key);
                            final String encryptedValue = sharedPreferences.getString(keyHash, null);
                            if (encryptedValue == null) {
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 145..158
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 195..208
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 210..223

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

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

                        @Override
                        public float getFloat(String key, float defaultValue) {
                            final String keyHash = encryptionProtocol.deriveContentKey(key);
                            final String encryptedValue = sharedPreferences.getString(keyHash, null);
                            if (encryptedValue == null) {
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 145..158
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 180..193
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 195..208

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

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

                        @Override
                        public long getLong(String key, long defaultValue) {
                            final String keyHash = encryptionProtocol.deriveContentKey(key);
                            final String encryptedValue = sharedPreferences.getString(keyHash, null);
                            if (encryptedValue == null) {
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 145..158
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 180..193
                    armadillo/src/main/java/at/favre/lib/armadillo/SecureSharedPreferences.java on lines 210..223

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

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

                            public ArmadilloSharedPreferences build() {
                                if (fingerprint == null) {
                                    throw new IllegalArgumentException("No encryption fingerprint is set - see encryptionFingerprint() methods");
                                }
                    
                    
                    Severity: Minor
                    Found in armadillo/src/main/java/at/favre/lib/armadillo/Armadillo.java - About 1 hr to fix

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

                          @Test
                          @UiThreadTest
                          public void testSecurePreferenceChangeNotification() {
                              ArmadilloSharedPreferences armadilloSharedPreferences = create("fingerprint", null).build();
                              AtomicBoolean matched = new AtomicBoolean(false);
                      armadillo/src/androidTest/java/at/favre/lib/armadillo/SecureSharedPreferencesTest.java on lines 81..95

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

                      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

                          @Test
                          @UiThreadTest
                          public void testSecurePreferenceNotMatching() {
                              ArmadilloSharedPreferences armadilloSharedPreferences = create("fingerprint", null).build();
                              AtomicBoolean matched = new AtomicBoolean(false);
                      armadillo/src/androidTest/java/at/favre/lib/armadillo/SecureSharedPreferencesTest.java on lines 65..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 79.

                      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