MarshallAsch/veil-droid

View on GitHub

Showing 97 of 98 total issues

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

package ca.marshallasch.veil.comparators;

import java.util.Comparator;

import ca.marshallasch.veil.proto.DhtProto;
app/src/main/java/ca/marshallasch/veil/comparators/PostAgeComparator.java on lines 1..25

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

package ca.marshallasch.veil.comparators;

import java.util.Comparator;

import ca.marshallasch.veil.proto.DhtProto;
app/src/main/java/ca/marshallasch/veil/comparators/CommentComparator.java on lines 1..24

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

Method createPost has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static DhtProto.Post createPost(String title, String message, @NonNull DhtProto.User author, @Nullable List<String> tags, boolean anonymous) {
Severity: Minor
Found in app/src/main/java/ca/marshallasch/veil/utilities/Util.java - About 35 mins to fix

    Method entryEquals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static boolean entryEquals(DhtProto.DhtWrapper a, DhtProto.DhtWrapper b) {
    
            if (a == null && b == null) {
                return true;
            }
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/comparators/EntryComparator.java - About 35 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 onUpgrade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            if(oldVersion < 3){
                Migrations.upgradeV3(db);
            }
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/database/Database.java - About 35 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 getPostOrComment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        @Nullable
        public DhtProto.DhtWrapper getPostOrComment(String hash) {
    
            List<DhtProto.DhtWrapper> list = hashMap.get(hash);
    
    
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/HashTableStore.java - About 35 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 sort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        @UiThread
        public void sort(SortOption option) {
    
            switch (option) {
                case ALPHA_TITLE_ASC:
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/PostListAdapter.java - About 35 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

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

            if(bundle != null) {
               try{
                   postObject = DhtProto.Post.parseFrom(bundle.getByteArray(getString(R.string.post_object_key)));
               } catch (InvalidProtocolBufferException e){
                   e.printStackTrace();
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/FragmentViewPost.java and 1 other location - About 30 mins to fix
    app/src/main/java/ca/marshallasch/veil/FragmentViewPost.java on lines 65..71

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

    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

            ViewInteraction materialButton5 = onView(
                    allOf(withId(R.id.view_btn), withText("View"),
                            childAtPosition(
                                    childAtPosition(
                                            withId(R.id.list_view),
    Severity: Minor
    Found in app/src/androidTest/java/ca/marshallasch/veil/MainUITest.java and 1 other location - About 30 mins to fix
    app/src/androidTest/java/ca/marshallasch/veil/MainUITest.java on lines 203..210

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

    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

            } else if (savedInstanceState != null){
                try{
                    postObject = DhtProto.Post.parseFrom(savedInstanceState.getByteArray(getString(R.string.post_object_key)));
                } catch (InvalidProtocolBufferException e){
                    e.printStackTrace();
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/FragmentViewPost.java and 1 other location - About 30 mins to fix
    app/src/main/java/ca/marshallasch/veil/FragmentViewPost.java on lines 59..65

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

    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

    Avoid too many return statements within this method.
    Open

                    return;
    Severity: Major
    Found in app/src/main/java/ca/marshallasch/veil/FragmentSignUp.java - About 30 mins to fix

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

              ViewInteraction materialButton4 = onView(
                      allOf(withId(R.id.discover_forums_btn), withText("Discover Forums"),
                              childAtPosition(
                                      childAtPosition(
                                              withId(R.id.fragment_container),
      Severity: Minor
      Found in app/src/androidTest/java/ca/marshallasch/veil/MainUITest.java and 1 other location - About 30 mins to fix
      app/src/androidTest/java/ca/marshallasch/veil/MainUITest.java on lines 214..221

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

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

          @NonNull
          public Sync.SyncMessage getSync(MeshId peer, int version) {
      
              // get time last sent data
              Sync.SyncMessage.Builder builder = Sync.SyncMessage.newBuilder();
      Severity: Minor
      Found in app/src/main/java/ca/marshallasch/veil/DataStore.java - About 25 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 getPostsByAuthorId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public List<DhtProto.Post> getPostsByAuthorId(String authorHash) {
      
              List<String> hashes = db.getPostHashes();
      
              DhtProto.Post post;
      Severity: Minor
      Found in app/src/main/java/ca/marshallasch/veil/DataStore.java - About 25 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 findPostByHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          @Nullable
          public DhtProto.Post findPostByHash(String hash) throws TooManyResultsException
          {
              ArrayList<DhtProto.DhtWrapper> entries;
      Severity: Minor
      Found in app/src/main/java/ca/marshallasch/veil/HashTableStore.java - About 25 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 findCommentByHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          @Nullable
          public DhtProto.Comment findCommentByHash(String hash) throws TooManyResultsException
          {
              ArrayList<DhtProto.DhtWrapper> entries;
      Severity: Minor
      Found in app/src/main/java/ca/marshallasch/veil/HashTableStore.java - About 25 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 findUserByHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public Pair<String, DhtProto.User> findUserByHash(String userHash) throws TooManyResultsException
          {
              ArrayList<DhtProto.DhtWrapper> entries;
              synchronized (hashMap) {
      Severity: Minor
      Found in app/src/main/java/ca/marshallasch/veil/HashTableStore.java - About 25 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

      Severity
      Category
      Status
      Source
      Language