Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite DeviceUtils and Utils in Kotlin #2056

Merged
merged 3 commits into from
Sep 15, 2022

Conversation

nielsvanvelzen
Copy link
Member

Changes

  • Rewrite DeviceUtils and Utils in Kotlin

Issues

@nielsvanvelzen nielsvanvelzen added the refactor Improvements to code realiability, readability and quality label Sep 13, 2022
@nielsvanvelzen nielsvanvelzen added this to the v0.15.0 milestone Sep 13, 2022
/**
* A collection of utility methods, all static.
*/
object Utils {

Check warning

Code scanning / detekt

Too many functions inside a/an file/class/object/interface always indicate a violation of the single responsibility principle. Maybe the file/class/object/interface wants to manage too many things at once. Extract functionality which clearly belongs together.

Object 'Utils' with '15' functions detected. Defined threshold inside objects is set to '11'

return when {
maxRate == UserPreferences.MAX_BITRATE_AUTO && autoRate != null -> autoRate.toInt()
else -> (maxRate.toFloat() * 1000000).toInt()

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.

This expression contains a magic number. Consider defining it to a well named constant.

@JvmStatic
fun getSafeSeekPosition(position: Long, duration: Long): Long = when {
position >= duration -> (duration - 1000).coerceAtLeast(0)

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.

This expression contains a magic number. Consider defining it to a well named constant.
private const val FIRE_STICK_4K_MAX_MODEL = "AFTKA"

// Fire TV Cube Models
private const val FIRE_CUBE_MODEL_GEN_1 = "AFTA"

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `FIRE_CUBE_MODEL_GEN_1` is unused.

// Fire TV Cube Models
private const val FIRE_CUBE_MODEL_GEN_1 = "AFTA"
private const val FIRE_CUBE_MODEL_GEN_2 = "AFTR"

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `FIRE_CUBE_MODEL_GEN_2` is unused.
// Fire TV (Box) Models
private const val FIRE_TV_MODEL_GEN_1 = "AFTB"
private const val FIRE_TV_MODEL_GEN_2 = "AFTS"
private const val FIRE_TV_MODEL_GEN_3 = "AFTN"

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `FIRE_TV_MODEL_GEN_3` is unused.
@nielsvanvelzen nielsvanvelzen merged commit a0da207 into jellyfin:master Sep 15, 2022
@nielsvanvelzen nielsvanvelzen deleted the util-kt branch September 26, 2022 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improvements to code realiability, readability and quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants