SpotBugs (4.8.6) Analysis for app (spotbugsGplayDebug)

SpotBugs Analysis generated at: Mon, 17 Mar 2025 03:18:05 +0000

Package Code Size Bugs High Prio Bugs Medium Prio Bugs Low Prio Bugs Exp. Bugs Ratio
Overall (111 packages), (711 classes) 32442 313 4 309
com.nextcloud.talk.account 168 8 8
com.nextcloud.talk.activities 524 11 11
com.nextcloud.talk.adapters.messages 797 34 34
com.nextcloud.talk.application 1351 2 2
com.nextcloud.talk.call 787 1 1
com.nextcloud.talk.callbacks 40 2 2
com.nextcloud.talk.callnotification 45 2 2
com.nextcloud.talk.chat 117 6 6
com.nextcloud.talk.contacts 106 4 4
com.nextcloud.talk.conversation 66 4 4
com.nextcloud.talk.conversationcreation 69 2 2
com.nextcloud.talk.conversationinfo 51 2 2
com.nextcloud.talk.conversationinfoedit 39 2 2
com.nextcloud.talk.conversationlist 81 2 2
com.nextcloud.talk.conversationlist.viewmodels 49 2 2
com.nextcloud.talk.dagger.modules 1090 3 3
com.nextcloud.talk.diagnose 51 2 2
com.nextcloud.talk.events 273 1 1
com.nextcloud.talk.filebrowser.models 70 2 2
com.nextcloud.talk.filebrowser.webdav 106 4 4
com.nextcloud.talk.fullscreenfile 18 2 2
com.nextcloud.talk.invitation 39 2 2
com.nextcloud.talk.invitation.adapters 18 2 2
com.nextcloud.talk.jobs 867 61 1 60
com.nextcloud.talk.location 84 4 4
com.nextcloud.talk.lock 24 2 2
com.nextcloud.talk.messagesearch 49 2 2
com.nextcloud.talk.models 195 8 8
com.nextcloud.talk.openconversations 39 2 2
com.nextcloud.talk.polls.ui 120 10 10
com.nextcloud.talk.polls.viewmodels 96 2 2
com.nextcloud.talk.presenters 129 5 5
com.nextcloud.talk.profile 39 2 2
com.nextcloud.talk.raisehand.viewmodel 38 2 2
com.nextcloud.talk.receivers 120 8 8
com.nextcloud.talk.remotefilebrowser.activities 36 2 2
com.nextcloud.talk.services.firebase 18 2 2
com.nextcloud.talk.settings 51 2 2
com.nextcloud.talk.shareditems.activities 33 2 2
com.nextcloud.talk.signaling 410 1 1
com.nextcloud.talk.translate.ui 39 2 2
com.nextcloud.talk.ui 95 2 2
com.nextcloud.talk.ui.dialog 822 49 1 48
com.nextcloud.talk.utils 329 8 8
com.nextcloud.talk.utils.power 38 2 2
com.nextcloud.talk.utils.preferences.preferencestorage 30 2 2
com.nextcloud.talk.utils.singletons 103 6 6
com.nextcloud.talk.utils.ssl 192 6 6
com.nextcloud.talk.viewmodels 38 2 2
com.nextcloud.talk.webrtc 1342 14 2 12
fr.dudie.nominatim.client 107 1 1
PA / PA_PUBLIC_PRIMITIVE_ATTRIBUTE

SEI CERT rule OBJ01-J requires that accessibility to fields must be limited. Otherwise, the values of the fields may be manipulated from outside the class, which may be unexpected or undesired behaviour. In general, requiring that no fields are allowed to be public is overkill and unrealistic. Even the rule mentions that final fields may be public. Besides final fields, there may be other usages for public fields: some public fields may serve as "flags" that affect the behavior of the class. Such flag fields are expected to be read by the current instance (or the current class, in case of static fields), but written by others. If a field is both written by the methods of the current instance (or the current class, in case of static fields) and from the outside, the code is suspicious. Consider making these fields private and provide appropriate setters, if necessary. Please note that constructors, initializers and finalizers are exceptions, if only they write the field inside the class, the field is not considered as written by the class itself.

OCP / OCP_OVERLY_CONCRETE_COLLECTION_PARAMETER

This method uses specific collection interface/classes for parameters when only methods defined in the Collection class are used. Consider increasing the abstraction of the interface to make low impact changes easier to accomplish in the future.

Take the following example:


private void printList(List<String> list) {
    for (String s : list) {
        System.out.println(s);
    }
}
The parameter list is currently defined as an List, which is a specific collection interface. Specifying List is unnecessary here, because we aren't using any AList-specific methods (like get(0)). Instead of using the concrete definition, it is better to do something like:

private void printList(Collection<String> list) {
    ...
If the design ever changes, e.g. a Set is used instead, this code won't have to change.

IDEs tend to have tools to help generalize parameters. For example, in Eclipse, the refactoring tool Generalize Declared Type helps find an appropriate level of concreteness.

SIC / SIC_INNER_SHOULD_BE_STATIC

This class is an inner class, but does not use its embedded reference to the object which created it.  This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.  If possible, the class should be made static.

NP / NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE

The return value from a method is dereferenced without a null check, and the return value of that method is one that should generally be checked for null. This may lead to a NullPointerException when the code is executed.

LII / LII_LIST_INDEXED_ITERATING

This method uses an integer-based for loop to iterate over a java.util.List, by calling List.get(i) each time through the loop. The integer is not used for other reasons. It is better to use an Iterator instead, as depending on List implementation, iterators can perform better, and they also allow for exchanging of other collection types without issue.

UEC / UEC_USE_ENUM_COLLECTIONS

This class uses an ordinary set or map collection and uses an enum class as the key type. It is more performant to use the JDK 1.5 EnumSet or EnumMap classes.

DCN / DCN_NULLPOINTER_EXCEPTION

According to SEI Cert rule ERR08-J NullPointerException should not be caught. Handling NullPointerException is considered an inferior alternative to null-checking.

This non-compliant code catches a NullPointerException to see if an incoming parameter is null:


boolean hasSpace(String m) {
  try {
    String ms[] = m.split(" ");
    return names.length != 1;
  } catch (NullPointerException e) {
    return false;
  }
}

A compliant solution would use a null-check as in the following example:


boolean hasSpace(String m) {
    if (m == null) return false;
    String ms[] = m.split(" ");
    return names.length != 1;
}
MDM / MDM_STRING_BYTES_ENCODING

The behavior of the String(byte[] bytes) and String.getBytes() is undefined if the string cannot be encoded in the platform's default charset. Instead, use the String(byte[] bytes, String encoding) or String.getBytes(String encoding) constructor which accepts the string's encoding as an argument. Be sure to specify the encoding used for the user's locale.

As per the Java specifications, "UTF-8", "US-ASCII", "UTF-16" and "ISO-8859-1" will all be valid encoding charsets. If you aren't sure, try "UTF-8".

New in Java 1.7, you can specify an encoding from StandardCharsets, like StandardCharsets.UTF_8. These are generally preferrable because you don't have to deal with UnsupportedEncodingException.

MS / MS_EXPOSE_REP

A public static method returns a reference to a mutable object or an array that is part of the static state of the class. Any code that calls this method can freely modify the underlying array. One fix is to return a copy of the array.

SPP / SPP_PASSING_THIS_AS_PARM

This method calls an instance method passing the object that the method is called on as a parameter, such as foo.someMethod(foo); As you already have access to this object thru this, you don't need to pass it.

CE / CE_CLASS_ENVY

This method makes extensive use of methods from another class over methods of its own class. Typically this means that the functionality that is accomplished by this method most likely belongs with the class that is being used so liberally. Consider refactoring this method to be contained in that class, and to accept all the parameters needed in the method signature.

OCP / OCP_OVERLY_CONCRETE_PARAMETER

This method uses concrete classes for parameters when only methods defined in an implemented interface or superclass are used. Consider increasing the abstraction of the interface to make low impact changes easier to accomplish in the future.

Take the following example:


private void appendToList(ArrayList<String> list) {
    if (list.size() < 100) {
        list.add("Foo");
    }
}
The parameter list is currently defined as an ArrayList, which is a concrete implementation of the List interface. Specifying ArrayList is unnecessary here, because we aren't using any ArrayList-specific methods (like ensureCapacity() or trimToSize()). Instead of using the concrete definition, it is better to do something like:

private void appendToList(List<String> list) {
    ...
If the design ever changes, e.g. a LinkedList is used instead, this code won't have to change.

IDEs tend to have tools to help generalize parameters. For example, in Eclipse, the refactoring tool Generalize Declared Type helps find an appropriate level of concreteness.

ITU / ITU_INAPPROPRIATE_TOSTRING_USE

This method calls algorithmic operations on a String that was returned from a toString() method. As these methods are for debugging/logging purposes, it shouldn't be the basis of core logic in your code.

NP / NP_NULL_PARAM_DEREF

This method call passes a null value for a non-null method parameter. Either the parameter is annotated as a parameter that should always be non-null, or analysis has shown that it will always be dereferenced.

IOI / IOI_USE_OF_FILE_STREAM_CONSTRUCTORS

This method creates and uses a java.io.FileInputStream or java.io.FileOutputStream object. Unfortunately both of these classes implement a finalize method, which means that objects created will likely hang around until a full garbage collection occurs, which will leave excessive garbage on the heap for longer, and potentially much longer than expected. Java 7 introduced two ways to create streams for reading and writing files that do not have this concern. You should consider switching from these above classes to InputStream is = java.nio.file.Files.newInputStream(myfile.toPath()); OutputStream os = java.nio.file.Files.newOutputStream(myfile.toPath());

ITC / ITC_INHERITANCE_TYPE_CHECKING

This method uses the instanceof operator in a series of if/else statements to differentiate blocks of code based on type. If these types are related by inheritance, it is cleaner to just define a method in the base class, and use overridden methods in these classes.

SING / SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR

This class is using singleton design pattern and has non-private constructor (please note that a default constructor might exist which is not private). Given that, it is possible to create a copy of the object, thus violating the singleton pattern.
The easier solution would be making the constructor private.

SEI CERT MSC07-J rule

Dm / DM_DEFAULT_ENCODING

Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behavior to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.

SECHCK / HARD_CODE_KEY

Cryptographic keys should not be kept in the source code. The source code can be widely shared in an enterprise environment, and is certainly shared in open source. To be managed safely, passwords and secret keys should be stored in separate configuration files or keystores. (Hard coded passwords are reported separately by the Hard coded password pattern)

Vulnerable Code:

byte[] key = {1, 2, 3, 4, 5, 6, 7, 8};
SecretKeySpec spec = new SecretKeySpec(key, "AES");
Cipher aes = Cipher.getInstance("AES");
aes.init(Cipher.ENCRYPT_MODE, spec);
return aesCipher.doFinal(secretData);


References
CWE-321: Use of Hard-coded Cryptographic Key

NP / NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH

There is a statement or branch on an exception path that if executed guarantees that a value is null at this point, and that value that is guaranteed to be dereferenced (except on forward paths involving runtime exceptions).

CSI / CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME

This method uses a hand-typed String literal to specify a Charset encoding. As this class is compiled with JDK 7 (or better), and the charset in question is available as a constant from the java.nio.charset.StandardCharsets class, it is better to use the .name() method of the appropriate StandardCharsets constant.

The method in question doesn't directly support a Charset as a parameter, only a String. Still, instead of specifying something like "UTF-8" (and potentially mistyping it), use StandardCharsets.UTF_8.name().

USBR / USBR_UNNECESSARY_STORE_BEFORE_RETURN

This method stores the return result in a local variable, and then immediately returns the local variable. It would be simpler just to return the value that is assigned to the local variable, directly.

Instead of the following:


public float average(int[] arr) {
    float sum = 0;
    for (int i = 0; i < arr.length; i++) {
        sum += arr[i];
    }
    float ave = sum / arr.length;
    return ave;
}
Simply change the method to return the result of the division:

public float average(int[] arr) {
    float sum = 0;
    for (int i = 0; i < arr.length; i++) {
        sum += arr[i];
    }
    return sum / arr.length; //Change
}

IICU / IICU_INCORRECT_INTERNAL_CLASS_USE

This class makes use of internal API classes. As these classes are not documented, nor externally released as part of the API, they are subject to change or removal. You should not be using these classes.

Packages that shouldn't be used are: