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

[Glide 4.0.0-RC0][Lint] - Error: This method should only be accessed from tests or within private scope [VisibleForTests] Glide.tearDown(); #1977

Closed
jaredsburrows opened this issue May 30, 2017 · 12 comments
Labels
Milestone

Comments

@jaredsburrows
Copy link
Contributor

Auto generated code is causing lint issues:

GlideApp.java:50: Error: This method should only be accessed from tests or within private scope [VisibleForTests]
    Glide.init(glide);
    ~~~~~~~~~~~~~~~~~
GlideApp.java:57: Error: This method should only be accessed from tests or within private scope [VisibleForTests]
    Glide.tearDown();
    ~~~~~~~~~~~~~~~~

   Explanation for issues of type "VisibleForTests":
   With the @VisibleForTesting annotation you can specify an otherwise=
   attribute which specifies the intended visibility if the method had not
   been made more widely visible for the tests.

   This check looks for accesses from production code (e.g. not tests) where
   the access would not have been allowed with the intended production
   visibility.

2 errors, 0 warnings
:lintDebug FAILED
:cleanup

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ''.
> Lint found errors in the project; aborting build.
  
  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
@sjudd
Copy link
Collaborator

sjudd commented May 31, 2017

What version of android are you targeting/compiling against? I don't see this lint error. I'll add a suppression anyway, but if you give me the version info I can try to verify it actually works.

@sjudd sjudd added the bug label May 31, 2017
@sjudd sjudd added this to the 4.0 milestone May 31, 2017
@jaredsburrows
Copy link
Contributor Author

Compile/Target - API 25

@sjudd
Copy link
Collaborator

sjudd commented May 31, 2017

Same here, but I don't see the lint errors in the sample apps.

Out of curiosity, if you add @VisibleForTesting manually to those generated classes, do you still see the lint error?

sjudd added a commit to sjudd/glide that referenced this issue May 31, 2017
@jaredsburrows
Copy link
Contributor Author

Here is a trimmed down version of the the android gradle DSL. I am using com.android.tools.build:gradle:2.3.2.

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        targetSdkVersion 25
    }

    lintOptions {
        textReport true
        textOutput "stdout"
        checkAllWarnings true
        warningsAsErrors true
    }
}

@TWiStErRob
Copy link
Collaborator

@sjudd I don't think @VisibleForTesting is transitive; just because a method is visible for testing, it doesn't warrant it to call other methods that are visible for testing.

@jaredsburrows
Copy link
Contributor Author

jaredsburrows commented May 31, 2017 via email

@TWiStErRob
Copy link
Collaborator

TWiStErRob commented May 31, 2017

@jaredsburrows I don't think that's a good idea. That may hide bugs that are uncovered by lints implemented in the future. You can always add an external suppression in lint.xml

@jaredsburrows
Copy link
Contributor Author

jaredsburrows commented May 31, 2017 via email

@jaredsburrows
Copy link
Contributor Author

@TWiStErRob I am suppressing this via lint now but I should not have to. This is a problem introduced by 4.0.

@TWiStErRob
Copy link
Collaborator

yes, 4.0 is RC, Sam's ironing the kinks out, annotation processing is quite a new component of Glide, and since RC more people seem to be using it than alpha, so there're more issues coming up.

@jaredsburrows
Copy link
Contributor Author

jaredsburrows commented May 31, 2017

@TWiStErRob Yeah. So far it's great. I am just trying to help iron out these issues by reporting issues that I am finding! You guys always answer fast and are great help!

@sjudd sjudd closed this as completed in be4db99 Jun 15, 2017
@jaredsburrows
Copy link
Contributor Author

@sjudd Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants