lint

Proper way to handle Android Studio's NullPointerException lint warning

怎甘沉沦 提交于 2019-11-29 02:50:57
I'm new to android/java programming and am confused how to properly deal with this warning. Method invocation '' may produce 'Java.lang.NullPointerException' Should I be ussing assert to remove the warning? Or rather a runtime exception? Any help would be appreciated. matiash I doubt this question can be answered conclusively, as it's a matter of opinion. Or at least I believe so -- an opinion too. :) I understand you want "0 warnings" (a very laudable goal) but there's probably not a "one size fits all" issue. That said... Things I believe you should not do: Use assert . While you can add an

create-react-app+eslint配置+precommit

吃可爱长大的小学妹 提交于 2019-11-29 00:44:24
1、根路径增加.eslintignore文件: build/*.js config/*.js 2、安装依赖: eslint-config-airbnb 3、根路径增加.eslintrc.js文件 module.exports = { "parser": "babel-eslint", "env": { "browser": true, "es6": true, "node": true }, "parserOptions": { "ecmaVersion": 6, "sourceType": "module" }, "extends": "airbnb", "plugins": ["react-hooks"], "rules": { "react/jsx-filename-extension": [1, { extensions: [".js"] }], // 允许js文件使用jsx语法 "react/prop-types": 1, // 开启PropTypes验证 "react/prefer-stateless-function": 1, // 建议使用函数式组件 "linebreak-style": 0, "react/jsx-one-expression-per-line": 0, "react-hooks/rules-of-hooks": "error", // 检查

Android Lint: how to ignore missing translation warnings in a regional locale string file that purposely only overrides some default translations?

假如想象 提交于 2019-11-28 23:39:26
问题 Is it possible to translate some strings, but not all, in a separate resource file without Lint complaining about MissingTranslation ? For example: my app's strings are all in res/values/strings.xml . One of the strings is <string name="postal_code">Postal Code</string> Since "postal code" is usually called "zip code" in the US, I want to add another resource res/values-en-rUS/strings.xml with contents: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="postal_code">Zip Code<

Resolved color instead of a resource id

让人想犯罪 __ 提交于 2019-11-28 21:03:59
Recently I've seen appeared a lint error in my code: Should pass resolved color instead of resource id here: getResources().getColor(R.color.maps_list_background_color) MyClass.java /myapp/android/maps line 107 Android Lint Problem I know how to resolve it the answer is in the error, the thing is I don't get why they have added this error in the linter. Methods that take a color in the form of an integer should be passed an RGB triple, not the actual color resource id. You must call getResources.getColor(resource). The function you are calling is expecting an integer that is an RGB triple, not

How to configure PyLint to check all things PEP8 checks?

痴心易碎 提交于 2019-11-28 20:14:13
Searching for an answer on PyLint's mailing list brings no interesting results. PyLint is known to be very customizable so I guess this should be possible... The reason I would like PyLint to check compliance with PEP8 is because PyDev has much better support for PyLint than it has for PEP8. It's easier to have one tool doing all checks than having to use two. I also asked this question on PyLint's mailing list at http://thread.gmane.org/gmane.comp.python.logilab/1039 Example of diagnostic messages from PEP8 which I don't get from PyLint: E203 whitespace before ':' E225 missing whitespace

Where can I find an actively developed lint tool for Ruby?

时光怂恿深爱的人放手 提交于 2019-11-28 16:31:28
Most of the code I write is in Ruby, and every once in a while, I make some typo which only gets caught after a while. This is irritating when I have my scripts running long tasks, and return to find I had a typo. Is there an actively developed lint tool for Ruby that could help me overcome this? Would it be possible to use it across a system that works with a lot of source files, some of them loaded dynamically? Take this snippet as an example: a = 20 b = 30 puts c To win bounty, show me a tool that will detect the c variable as not created/undefined. You could give Diamondback Ruby a try. It

Is there a simple CLI Java linter? [closed]

不羁的心 提交于 2019-11-28 16:16:54
问题 I've been trying to find a Java linter capable of running on the CLI that is separate from Eclipse that I can call as a commit hook for git or from our automated build script. Does such a thing exist? Ideally it needs to check for unused imports and variables, that style guidelines are followed, exceptions are used properly, etc. Though some subset of those features would be better that what we have now - nothing! 回答1: Findbugs for finding existing bugs. VERY GOOD! PMD for finding patterns

The result of subscribe is not used

自古美人都是妖i 提交于 2019-11-28 15:37:07
I've upgraded to Android Studio 3.1 today, which seems to have added a few more lint checks. One of these lint checks is for one-shot RxJava2 subscribe() calls that are not stored in a variable. For example, getting a list of all players from my Room database: Single.just(db) .subscribeOn(Schedulers.io()) .subscribe(db -> db.playerDao().getAll()); Results in a big yellow block and this tooltip: The result of subscribe is not used What is the best practice for one-shot Rx calls like this? Should I keep hold of the Disposable and dispose() on complete? Or should I just @SuppressLint and move on?

how do i get a java maven build to fail for compiler warnings?

独自空忆成欢 提交于 2019-11-28 10:49:36
I am trying: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> <compilerArgument>-Werror</compilerArgument> <fork>true</fork> </configuration> </plugin> but with no joy. Any ideas now to get medieval on such errors as suggested at this blog post ? alex.p EDIT: This answer is outdated however I can't delete it as it was an accepted answer at the time. This a bug with Maven see: https://issues.apache.org/jira/browse/MCOMPILER-120 it's been fixed in 2.4 of the Maven

Ignoring return values in C

只谈情不闲聊 提交于 2019-11-28 07:10:24
Lately, I started using lint for static code analysis. One of the warning I get sometimes is regarding this issue. Let's say for instance that I've got the following function: uint32_t foo( void ); And let's say that I delibertly ignore the return value of the function. To make the warning dissapear, one can write (void) foo(); My question is, what is the "proper" way to write code like this, should I continue as I always did, since the compiler doesn't complain about it, or should I use the void for clarity, so other code maintainer will know that I delibertly ignored the return value. When I