Showing 108 of 144 total issues
Method endFile
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Uri endFile(FileCacheEntry entry) throws RemoteException {
Uri tableUri;
boolean isVideo = MediaFile.isVideoFileType(mFileType) && mWidth > 0 && mHeight > 0;
if (isVideo) {
tableUri = Video.Media.CONTENT_URI;
Method dispatchKeyEvent
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
if (event.getRepeatCount() == 0 && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
doPauseResume();
- 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 updateSub
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private void updateSub(int subType, byte[] bytes, String encoding, int width, int height) {
if (mEventHandler != null) {
Message m = mEventHandler.obtainMessage(MEDIA_TIMED_TEXT, width, height);
Bundle b = m.getData();
if (subType == SUBTITLE_TEXT) {
- 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 onCreate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideUI();
Method onRequestPermissionsResult
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: {
- 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 handleStringTag
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public void handleStringTag(String name, byte[] valueBytes, String valueEncoding) {
String value;
try {
value = new String(valueBytes, valueEncoding);
} catch (Exception e) {
- 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 saveMiniThumbToFile
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected synchronized void saveMiniThumbToFile(byte[] data, long id, long magic) throws IOException {
RandomAccessFile r = miniThumbDataFile();
if (r == null)
return;
Method getMiniThumbFromFile
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected synchronized byte[] getMiniThumbFromFile(long id, byte[] data) {
RandomAccessFile r = miniThumbDataFile();
if (r == null)
return null;
Method setVideoLayout
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void setVideoLayout(int layout, float aspectRatio) {
LayoutParams lp = getLayoutParams();
Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
float windowRatio = windowWidth / (float) windowHeight;
Method onKeyDown
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL;
if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE) {
Method doScanFile
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public Uri doScanFile(String path, long lastModified, long fileSize, boolean scanAlways) {
Uri result = null;
try {
FileCacheEntry entry = beginFile(path, lastModified, fileSize);
if (entry != null && (entry.mLastModifiedChanged || scanAlways)) {
- 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 convertToInt
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static int convertToInt(String str) throws NumberFormatException {
int s, e;
for (s = 0; s < str.length(); s++)
if (Character.isDigit(str.charAt(s)))
break;
- 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 createSurface
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public GL createSurface(Surface surface) {
if (mEgl == null)
throw new RuntimeException("egl not initialized");
if (mEglDisplay == null)
throw new RuntimeException("eglDisplay not initialized");
- 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 show
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public void show(int timeout) {
if (!mShowing && mAnchor != null && mAnchor.getWindowToken() != null) {
if (mPauseButton != null)
mPauseButton.requestFocus();
- 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 surfaceChanged
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
mSurfaceWidth = w;
mSurfaceHeight = h;
boolean isValidState = (mTargetState == STATE_PLAYING);
boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h);
- 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 attachMediaController
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private void attachMediaController() {
if (mMediaPlayer != null && mMediaController != null) {
mMediaController.setMediaPlayer(this);
View anchorView = this.getParent() instanceof View ? (View) this.getParent() : this;
mMediaController.setAnchorView(anchorView);
- 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 onPrepared
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void onPrepared(MediaPlayer mp) {
Log.d("onPrepared");
mCurrentState = STATE_PREPARED;
// mTargetState = STATE_PLAYING;
Method handleStringTag
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void handleStringTag(String name, byte[] valueBytes, String valueEncoding) {
String value;
try {
value = new String(valueBytes, valueEncoding);
} catch (Exception e) {
Method getMagic
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected synchronized long getMagic(long id) {
RandomAccessFile r = miniThumbDataFile();
if (r != null) {
long pos = id * BYTES_PER_MINTHUMB;
FileLock lock = null;
Method requestPermissions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void requestPermissions(final Activity thisActivity, View videosFragmentView) {
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?