mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-24817 Fixed: False positive: Method may be 'static' when docstring is present
Update PyMethodMayBeStaticInspection to consider more methods as empty ones.
This commit is contained in:
committed by
Semyon Proshev
parent
cb598c94c5
commit
934f3da2a5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -78,10 +78,7 @@ public class PyMethodMayBeStaticInspection extends PyInspection {
|
||||
if (!attributes.isEmpty()) return;
|
||||
if (isTestElement(node)) return;
|
||||
|
||||
final PyStatementList statementList = node.getStatementList();
|
||||
final PyStatement[] statements = statementList.getStatements();
|
||||
|
||||
if (statements.length == 1 && statements[0] instanceof PyPassStatement) return;
|
||||
if (PyUtil.isEmptyFunction(node)) return;
|
||||
|
||||
final PyParameter[] parameters = node.getParameterList().getParameters();
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
def foo(self):
|
||||
"""Do something"""
|
||||
pass
|
||||
+6
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -105,6 +105,11 @@ public class PyMethodMayBeStaticInspectionTest extends PyTestCase {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, () -> doTest());
|
||||
}
|
||||
|
||||
// PY-24817
|
||||
public void testDocumentedEmpty() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyMethodMayBeStaticInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user