Giter Site home page Giter Site logo

Comments (15)

romani avatar romani commented on May 18, 2024

please provide more exact test case, to let us see a problem.

from checkstyle.

apennebaker avatar apennebaker commented on May 18, 2024

My project is organized in a Maven structure, so my Java code refers to code in various dependency libraries, which only get onto the CLASSPATH with Maven's help.

I can successfully integrate Checkstyle with Maven using a Maven plugin, so mvn checkstyle:checkstyle works well. But I'd like to be able to use raw Checkstyle, as checkstyle -c ... -r ., and I'd like Checkstyle to hide errors relating to things it can't find, such as Unable to get class information for TException..

from checkstyle.

romani avatar romani commented on May 18, 2024

Can you share a code, or part of it, reproduce problem? I can not image how checkstyle could try to investigate classes that it does not have as files in your project folder. I need to see a problem.

from checkstyle.

apennebaker avatar apennebaker commented on May 18, 2024

@romani It's not open source.

What I can say is that raw CLI checkstyle has trouble loading classes, where mvn checkstyle:checkstyle does not. That's not a problem, but it would be nice if Checkstyle simply ignored class-not-found sort of errors:

~/Desktop/src/checkstyle$ grep "Unable to get class information for" -r .
./src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/messages.properties:redundant.throws.classInfo=Unable to get class information for {0}.
./src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/messages.properties:javadoc.classInfo=Unable to get class information for {0} tag ''{1}''.
./src/tests/com/puppycrawl/tools/checkstyle/checks/coding/RedundantThrowsCheckTest.java://             "35:27: Unable to get class information for WrongException.",

from checkstyle.

apennebaker avatar apennebaker commented on May 18, 2024

I have an idea -- is there a config.xml setting I can write to hide these? I'd be happy with that.

from checkstyle.

romani avatar romani commented on May 18, 2024

We need test case to reproduce a problem. From all close sources it is possible to make open sources by removing company names and all logic from Class files, and obfuscate names if that is so critical. In other case issue will be marked as incomplete and closed.

Fortunately I have close source Thrift project, and reproduced problem:

Steps to reproduce:
in Ubuntu install checkstyle as package from repo "sudo apt-get install checkstyle"
copy following source to local disc:

package com.gen;

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
import java.util.BitSet;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("serial")
public class DayValue implements org.apache.thrift.TBase<DayValue, DayValue._Fields>, java.io.Serializable, Cloneable {

    @Override
    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TField field;
        iprot.readStructBegin();
        iprot.readStructEnd();

        // check for required fields of primitive type, which can't be checked in the validate method
        validate();
    }

}
checkstyle -c file:///home/rivanov/Temp/1/checkstyle-5.6/sun_checks.xml -r . | grep "Unable to get class information"

but it woks without problem on checkstyle 5.6:

java -jar /home/rivanov/Temp/1/checkstyle-5.6/checkstyle-5.6-all.jar -c /home/rivanov/Temp/1/checkstyle-5.6/sun_checks.xml -r . | grep "Unable to get class information"

in Ubuntu 12.04 there is an old Checkstyle package :

08:34 ~/Temp $ dpkg -l checkstyle
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                           Version                        Description
+++-==============================-==============================-============================================================================
ii  checkstyle                     5.4-1                          checks Java source against a coding standard

Please let me know how you installed CLI, and what version checkstyle you use.

from checkstyle.

apennebaker avatar apennebaker commented on May 18, 2024

@romani Thank you so much for taking the time to help reproduce this!

I'm using the checkstyle 5.6 package from Homebrew, as I'm on a Mac, not Ubuntu. I apologize for not providing the version earlier; I didn't know how to check it (speaking of which, #9).

from checkstyle.

romani avatar romani commented on May 18, 2024

ok, please open jar file of checkstyle and search for /META-INF/MANIFEST.MF file, and let me know version
search for files: checkstyle-5.6-all.jar, checkstyle-5.6.jar at https://github.com/mxcl/homebrew/wiki/FAQ#where-does-stuff-get-downloaded

In my case (latest version) it is :

Manifest-Version: 1.0
Implementation-Title: checkstyle
Implementation-Version: 5.6
Implementation-Vendor-Id: com.puppycrawl.tools
Build-Jdk: 1.7.0_07
Built-By: oliver
Specification-Title: checkstyle
Created-By: Apache Maven
Specification-Version: 5.6
Main-Class: com.puppycrawl.tools.checkstyle.Main
Archiver-Version: Plexus Archiver

from checkstyle.

apennebaker avatar apennebaker commented on May 18, 2024

Mine says:

Manifest-Version: 1.0
Implementation-Title: checkstyle
Implementation-Version: 5.6
Implementation-Vendor-Id: com.puppycrawl.tools
Build-Jdk: 1.7.0_07
Built-By: oliver
Specification-Title: checkstyle
Created-By: Apache Maven
Specification-Version: 5.6
Main-Class: com.puppycrawl.tools.checkstyle.Main
Archiver-Version: Plexus Archiver

from checkstyle.

romani avatar romani commented on May 18, 2024

strange, you have latest, can you please download zip from web site and launch it from jar , Example:

java -jar /home/rivanov/Temp/1/checkstyle-5.6/checkstyle-5.6-all.jar -c /home/rivanov/Temp/1/checkstyle-5.6/sun_checks.xml -r . | grep "Unable to get class information"

from checkstyle.

isopov avatar isopov commented on May 18, 2024

I have reproduced the issue:

  1. Download checkstyle-5.6-bin.tar.gz distribution.
  2. Extract it.
  3. In bundled sun_checks.xml comment DoubleCheckedLocking (with this check turned on checkstyle will not start at all)
  4. Create file Test.java
import org.apache.thrift.TException;
public class Test{
    public void foo() throws TException{
    }
}
  1. Run checkstyle with:
$java -jar checkstyle-5.6-all.jar -c sun_checks.xml Test.java | grep "Unable"

/home/isopov/Documents/Downloads/checkstyle-5.6/Test.java:4:34: Unable to get class information for TException.

from checkstyle.

apennebaker avatar apennebaker commented on May 18, 2024

@isopov Sure thing!

Trace:

$ cat Test.java 
import org.apache.thrift.TException;
public class Test{
  public void foo() throws TException{
  }
}
$ wget http://downloads.sourceforge.net/project/checkstyle/checkstyle/5.6/checkstyle-5.6-bin.tar.gz
$ tar xvf checkstyle-5.6-bin.tar.gz
$ cd checkstyle-5.6/
$ grep Double sun_checks.xml 
        <!-- module name="DoubleCheckedLocking"/ -->    <!-- MY FAVOURITE -->
$ java -jar checkstyle-5.6-all.jar -c sun_checks.xml ../Test.java | grep Unable
/Users/apennebaker/Downloads/checkstyle-5.6/../Test.java:3:28: Unable to get class information for TException.

System:

$ specs java os
Specs:

specs 0.4
https://github.com/mcandre/specs#readme

mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
Maven home: /usr/share/maven
Java version: 1.6.0_51, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"

echo $CLASSPATH


echo $JAVA_HOME
/Library/Java/Home

java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

system_profiler SPSoftwareDataType | grep 'System Version'
      System Version: OS X 10.8.5 (12F37)

from checkstyle.

hboutemy avatar hboutemy commented on May 18, 2024

see http://sourceforge.net/p/checkstyle/bugs/703/

from checkstyle.

romani avatar romani commented on May 18, 2024

RedundantThrows Check will be deprecated soon, as it is too buggy, please use it with caution.
See details at #177 (comment).

from checkstyle.

ychulovskyy avatar ychulovskyy commented on May 18, 2024

@romani Could you please close the issue since RedundantThrowsCheck was removed from the project.

from checkstyle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.