相关疑难解决方法(0)

有没有办法忽略一个FindBugs警告?

对于PMD,如果要忽略特定警告,可以使用// NOPMD该行来忽略该行.

FindBugs有类似的东西吗?

java warnings findbugs suppress-warnings

183
推荐指数
6
解决办法
9万
查看次数

如何抑制FindBugs警告(硬编码引用绝对路径名)?

我只是测试开源软件Geonetwork的一些东西,现在我想将一个形状文件从我的postGIS数据库导出到我的计算机但我无法测试它因为我总是得到一个findbugs警告:硬编码引用org中的绝对路径名. fao.geonet.services.resources.Download.exec(Element,ServiceContext)

有谁知道如何抑制或避免这种警告?或者另一种解决方案我如何测试导出是否有效?

这是代码:

  ` Map parameter1= new HashMap();
    parameter1.put("dbtype", "postgis");        
    parameter1.put("host", "localhost");        
    parameter1.put("port", "5433");  
    parameter1.put("database", "geonetwork");
    parameter1.put("schema", "mydata");
    parameter1.put("user", "postgres");        
    parameter1.put("passwd", "dominik1");
    parameter1.put("Expose primary keys", false);
    parameter1.put(PostgisNGDataStoreFactory.VALIDATECONN, true);
    parameter1.put(PostgisNGDataStoreFactory.MAX_OPEN_PREPARED_STATEMENTS, 100);
    parameter1.put(PostgisNGDataStoreFactory.LOOSEBBOX, true);
    parameter1.put(PostgisNGDataStoreFactory.PREPARED_STATEMENTS, true); 
    System.out.println("parameter1: " + parameter1);

    DataStore pds = new PostgisNGDataStoreFactory().createDataStore(parameter1);
    FeatureSource fs = pds.getFeatureSource("dano");

    SimpleFeatureCollection fc = (SimpleFeatureCollection) fs.getFeatures();
    SimpleFeature f = (SimpleFeature) fc.toArray()[0];

    // create shapefile

    File sfile = new File("C:/Users/Tinis/Downloads/dano.zip");            
    parameter1 = new HashMap();
    parameter1.put("url", sfile.toURI().toURL());
    parameter1.put("create spatial index", Boolean.FALSE);


    DirectoryDataStore dds = new …
Run Code Online (Sandbox Code Playgroud)

java findbugs absolute-path suppress-warnings hardcoded

7
推荐指数
1
解决办法
6151
查看次数

在Eclipse中抑制FindBugs警告

我使用字符串作为锁,因此要确保该对象是一个新实例.FindBugs抱怨,因为直接定义字符串通常更有效(使用双引号).我的代码看起来像:

/** A lock for the list of inputs. */
@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_STRING_CTOR")
//We want a new String object here as this is a lock.
private final Object inputListLock = new String("inputListLock");
Run Code Online (Sandbox Code Playgroud)

我在这里做错了吗?Eclipse FindBugs插件仍然将此报告为一个问题:

Pattern id: DM_STRING_CTOR, type: Dm, category: PERFORMANCE

Using the java.lang.String(String) constructor wastes memory because the object so constructed will be functionally indistinguishable from the String passed as a parameter.  Just use the argument String directly.

java eclipse findbugs suppress-warnings

3
推荐指数
1
解决办法
4653
查看次数