yashketkar/video-player

View on GitHub

Showing 144 of 144 total issues

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) {
Severity: Minor
Found in vitamio/src/io/vov/vitamio/widget/VideoView.java - About 1 hr to fix

    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;
    Severity: Minor
    Found in vitamio/src/io/vov/vitamio/widget/VideoView.java - About 1 hr to fix

      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);
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/widget/VideoView.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 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;
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/utils/StringUtils.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 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");
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/EGL.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 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);
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/widget/VideoView.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 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)) {
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/MediaScanner.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 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();
      
      
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/widget/MediaController.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 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;
      
      
      Severity: Minor
      Found in vitamio/src/io/vov/vitamio/widget/VideoView.java - About 1 hr to fix

        Method parseTrackInfo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private SparseArray<MediaFormat> parseTrackInfo(byte[] tracks, String encoding) {
            SparseArray<MediaFormat> trackSparse = new SparseArray<MediaFormat>();
            String trackString;
            int trackNum;
            try {
        Severity: Minor
        Found in vitamio/src/io/vov/vitamio/MediaPlayer.java - About 1 hr to fix

          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) {
          Severity: Minor
          Found in vitamio/src/io/vov/vitamio/MediaScanner.java - About 1 hr to fix

            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?
            Severity: Minor
            Found in app/src/main/java/com/yashketkar/ykplayer/VideosFragment.java - About 1 hr to fix

              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;
              Severity: Minor
              Found in vitamio/src/io/vov/vitamio/provider/MiniThumbFile.java - About 1 hr to fix

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

                    public static void d(String msg, Object... args) {
                        try {
                            if (BuildConfig.DEBUG) 
                                android.util.Log.d(TAG, String.format(msg, args));
                        } catch (MissingFormatArgumentException e) {
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/utils/Log.java and 1 other location - About 1 hr to fix
                vitamio/src/io/vov/vitamio/utils/Log.java on lines 25..33

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

                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

                    public static void i(String msg, Object... args) {
                        try {
                            if (BuildConfig.DEBUG) 
                                android.util.Log.i(TAG, String.format(msg, args));
                        } catch (MissingFormatArgumentException e) {
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/utils/Log.java and 1 other location - About 1 hr to fix
                vitamio/src/io/vov/vitamio/utils/Log.java on lines 35..43

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

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

                  private SparseArray<MediaFormat> parseTrackInfo(byte[] tracks, String encoding) {
                    SparseArray<MediaFormat> trackSparse = new SparseArray<MediaFormat>();
                    String trackString;
                    int trackNum;
                    try {
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/MediaPlayer.java - About 55 mins 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 setDataSource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  public void setDataSource(Context context, Uri uri, Map<String, String> headers) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
                    if (context == null || uri == null)
                      throw new IllegalArgumentException();
                    String scheme = uri.getScheme();
                    if (scheme == null || scheme.equals("file")) {
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/MediaPlayer.java - About 55 mins 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 setDataSource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  public void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException,
                      SecurityException, IllegalStateException {
                    if (context == null || uri == null)
                      throw new IllegalArgumentException();
                    String scheme = uri.getScheme();
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/MediaMetadataRetriever.java - About 55 mins 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 onLayout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  @Override
                  protected void onLayout(boolean changed, int l, int t, int r, int b) {
                    int count = getChildCount();
                    mWidth = getMeasuredWidth();
                    mHeight = getMeasuredHeight();
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/widget/CenterLayout.java - About 55 mins 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 getMiniThumbFromFile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  protected synchronized byte[] getMiniThumbFromFile(long id, byte[] data) {
                    RandomAccessFile r = miniThumbDataFile();
                    if (r == null)
                      return null;
                
                
                Severity: Minor
                Found in vitamio/src/io/vov/vitamio/provider/MiniThumbFile.java - About 55 mins 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