MarshallAsch/veil-droid

View on GitHub

Showing 97 of 98 total issues

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

    @WorkerThread
    public int getTotalEntries(@IntRange(from = 0, to = 3) int protocolVersion) {

        String selection = SyncStatsEntry.COLUMN_MESSAGE_TYPE + " = ?";
        String[] selectionArgs = {String.valueOf(protocolVersion)};
app/src/main/java/ca/marshallasch/veil/database/Database.java on lines 1274..1299

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

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

    @WorkerThread
    public int getTotalMessageSize(@IntRange(from = 0, to = 3) int protocolVersion) {

        String selection = SyncStatsEntry.COLUMN_MESSAGE_TYPE + " = ?";
        String[] selectionArgs = {String.valueOf(protocolVersion)};
app/src/main/java/ca/marshallasch/veil/database/Database.java on lines 1346..1371

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

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

        switch (Util.checkPasswords(password, passwordConf)) {

            case TOO_SIMPLE:
                Snackbar.make(getActivity().findViewById(R.id.top_view), R.string.password_complexity, Snackbar.LENGTH_SHORT).show();
                return;
Severity: Major
Found in app/src/main/java/ca/marshallasch/veil/FragmentSignUp.java and 1 other location - About 1 hr to fix
app/src/main/java/ca/marshallasch/veil/FragmentChangePassword.java on lines 99..112

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

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

        switch (Util.checkPasswords(newPassword, newPasswordConf)) {

            case TOO_SIMPLE:
                Snackbar.make(getActivity().findViewById(R.id.top_view), R.string.password_complexity, Snackbar.LENGTH_SHORT).show();
                return;
app/src/main/java/ca/marshallasch/veil/FragmentSignUp.java on lines 107..120

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

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

    @WorkerThread
    public boolean updatePassword(@Nullable  String email, @Nullable String oldPassword, @Nullable String newPassword) {

        if (email == null || oldPassword == null || newPassword == null) {
            return false;
Severity: Minor
Found in app/src/main/java/ca/marshallasch/veil/database/Database.java - About 1 hr to fix

    Method getUser has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Nullable
        @WorkerThread
        public DhtProto.User getUser(@Nullable String uuid) {
    
            if (uuid == null) {
    Severity: Minor
    Found in app/src/main/java/ca/marshallasch/veil/database/Database.java - About 1 hr to fix

      Method onBindViewHolder has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {
      
              if (holder.getItemViewType() == 0) {
                  return;
      Severity: Minor
      Found in app/src/main/java/ca/marshallasch/veil/PostListAdapter.java - About 1 hr to fix

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

            @Override
            public Filter getFilter() {
                /*
                 * This class is the tag filter. The CharSequence must be a list of tags that are
                 * denominated with a ':' character.
        Severity: Minor
        Found in app/src/main/java/ca/marshallasch/veil/PostListAdapter.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 findUsersByName has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            @Nullable
            public List<Pair<String, DhtProto.User>> findUsersByName(String name)
            {
                if (name == null) {
        Severity: Minor
        Found in app/src/main/java/ca/marshallasch/veil/HashTableStore.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 findCommentsByPost has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            @Deprecated
            @Override
            @NonNull
            public List<DhtProto.Comment> findCommentsByPost(String postHash)
            {
        Severity: Minor
        Found in app/src/main/java/ca/marshallasch/veil/HashTableStore.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 upgradeV8 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static void upgradeV8(SQLiteDatabase db) {
        
                String[] projection = {
                        KnownPostsContract.KnownPostsEntry.COLUMN_POST_HASH,
                        KnownPostsContract.KnownPostsEntry.COLUMN_COMMENT_HASH,
        Severity: Minor
        Found in app/src/main/java/ca/marshallasch/veil/database/Migrations.java - About 1 hr to fix

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

                      case REQUEST_DATA_V1:
          
                          Log.d("REQUEST_DATA_V1", "received request for data");
                          // if someone sent a message asking for data send a response with everything
          
          
          app/src/main/java/ca/marshallasch/veil/controllers/RightMeshController.java on lines 199..219

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

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

                  @Override
                  public void handleMessage(Message msg) {
                      switch (msg.what){
                          case ACTION_VIEW_MESH_SETTINGS:
                              rightMeshController.showMeshSettings();
          Severity: Minor
          Found in app/src/main/java/ca/marshallasch/veil/services/VeilService.java - About 1 hr to fix

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

                        case REQUEST_DATA_V2:
            
                            Log.d("REQUEST_DATA_V2", "received request for data");
                            // if someone sent a message asking for data send a response with everything
            
            
            app/src/main/java/ca/marshallasch/veil/controllers/RightMeshController.java on lines 177..198

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

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

                @Override
                public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                                         @Nullable Bundle savedInstanceState) {
            
                    View view = inflater.inflate(R.layout.fragment_settings, container, false);
            Severity: Minor
            Found in app/src/main/java/ca/marshallasch/veil/FragmentSettings.java - About 1 hr to fix

              Method updateLogSync has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @WorkerThread
                  public boolean updateLogSync(@NonNull String uuid, int additionalSize, int numRecords) {
              
                      String selection = SyncStatsEntry.COLUMN_DATA_SEND_ID + " = ?";
                      String[] selectionArgs = { uuid };
              Severity: Minor
              Found in app/src/main/java/ca/marshallasch/veil/database/Database.java - About 1 hr to fix

                Method upgradeV7 has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static void upgradeV7(SQLiteDatabase db) {
                
                        List<Pair<String, String>> knownPosts = new ArrayList<>();
                
                
                
                Severity: Minor
                Found in app/src/main/java/ca/marshallasch/veil/database/Migrations.java - About 1 hr to fix

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

                      @NonNull
                      @Override
                      public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                          View view;
                  
                  
                  Severity: Major
                  Found in app/src/main/java/ca/marshallasch/veil/PostListAdapter.java and 1 other location - About 1 hr to fix
                  app/src/main/java/ca/marshallasch/veil/CommentListAdapter.java on lines 101..113

                  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

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

                      @NonNull
                      @Override
                      public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                          View view;
                  
                  
                  app/src/main/java/ca/marshallasch/veil/PostListAdapter.java on lines 139..152

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

                      public static PasswordState checkPasswords(@NonNull String password, @NonNull String passwordConf)
                      {
                          if (password.length() == 0 || passwordConf.length() == 0) {
                              return PasswordState.MISSING;
                          }
                  Severity: Minor
                  Found in app/src/main/java/ca/marshallasch/veil/utilities/Util.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

                  Severity
                  Category
                  Status
                  Source
                  Language