Showing 152 of 153 total issues
Method newJotsByImage
has a Cognitive Complexity of 79 (exceeds 20 allowed). Consider refactoring. Open
fun newJotsByImage(vararg uris: Uri) = viewModelScope.launch {
loading.value = true
val exifToUri = HashMap<ExifInterface, ArrayList<Uri>>()
uris.forEach { uri ->
val uriExif = ExifInterface(app.contentResolver.openInputStream(uri) ?: return@forEach)
- Read upRead up
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
Class JotViewModel
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
/**
* ViewModel to representing a jot.
*/
class JotViewModel(
private val nyx: Nyx,
File AttachmentAdapter.java
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.larryhsiao.nyx.attachment;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
File JotViewModel.kt
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.larryhsiao.nyx.jot
import android.net.Uri
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
Method onBindViewHolder
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val jot = jots[position]
holder.itemView.itemJot_textView.text = buildTitle(holder.itemView.context, jot)
holder.itemView.itemJot_textView.paint.maskFilter = if (jot.privateLock()) {
BlurMaskFilter(
- Read upRead up
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 onBindViewHolder
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val jot = jots[position]
holder.itemView.itemJot_textView.text = buildTitle(holder.itemView.context, jot)
holder.itemView.itemJot_textView.paint.maskFilter = if (jot.privateLock()) {
BlurMaskFilter(
Method updateRemoteFiles
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateRemoteFiles(List<Attachment> remoteUpdates) {
try {
final List<Future<?>> asyncFuture = new ArrayList<>();
for (Attachment remoteUpdate : remoteUpdates) {
final File sourceFile = nyx.files().fileByUri(remoteUpdate.uri());
Method fire
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun fire() {
if (jot.privateLock()) {
BiometricPrompt(
fragment,
Executors.newSingleThreadExecutor(),
Method fire
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun fire() {
val conn = connSource.value()
try {
conn.prepareStatement( // language=H2
"""// --
Method value
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun value(): Jot {
try {
db.value().prepareStatement( // language=H2
"""//
INSERT INTO jots(content, createdTime, location, mood, VERSION, TITLE, PRIVATE, delete)
Method onCreateViewHolder
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
@NonNull
@Override
public ViewHolder onCreateViewHolder(
@NonNull ViewGroup parent, int viewType) {
ViewHolder holder;
Method updateRemotes
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateRemotes(List<Jot> remoteUpdates) {
final List<Future<?>> asyncFuture = new ArrayList<>();
for (Jot remoteUpdate : remoteUpdates) {
if (remoteUpdate.deleted()) {
asyncFuture.add(
Method value
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun value(): Jot {
try {
db.value().prepareStatement( // language=H2
"""
INSERT INTO jots(content, createdTime, location, mood, VERSION, ID, DELETE, TITLE, PRIVATE)
Method value
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun value(): Connection {
try {
Class.forName("org.h2.Driver")
} catch (e: ClassNotFoundException) {
e.printStackTrace()
Method fire
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void fire() {
try {
final InputStream stream = streamSource.value();
final HttpURLConnection conn = (HttpURLConnection) new URL(URL).openConnection();
Method updateLoginUi
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateLoginUi(View view) {
final TextView loginIndicator = view.findViewById(R.id.setting_login);
final TextView dropboxAccount = view.findViewById(R.id.setting_dropboxAccount);
final View syncButton = view.findViewById(R.id.setting_sync);
final Syncs syncs = getApp().getSyncs();
Method fire
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void fire() {
final List<Attachment> remoteUpdates = new ArrayList<>();
final Map<Long, Attachment> localUpdates = nyx.attachments()
.all()
Method fire
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void fire() {
if (uri.startsWith("http")) {
new HttpPreviewLoading(img, uri).fire();
} else {
- Read upRead up
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 compressImageToInternal
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void compressImageToInternal(
File internalRoot,
Attachment attachment,
String ext
) throws IOException {
Method fire
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun fire() {
try {
val conn = conSource.value()
val queryTagJot = conn.prepareStatement( // language=H2
"SELECT * FROM TAG_JOT WHERE TAG_ID=?2 AND JOT_ID=?1"