mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
drop "ignore in test code" checkbox and use "suppress for 'Tests' scope" quickfix
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ instanceof.check.for.this.display.name='instanceof' check for 'this'
|
||||
instanceof.check.for.this.problem.descriptor='instanceof' check for <code>#ref</code> #loc
|
||||
local.variable.of.concrete.class.display.name=Local variable of concrete class
|
||||
local.variable.of.concrete.class.problem.descriptor=Local variable ''{0}'' of concrete class <code>#ref</code> #loc
|
||||
magic.number.display.name="Magic number"
|
||||
magic.number.display.name=Magic number
|
||||
magic.number.problem.descriptor=Magic number <code>#ref</code> #loc
|
||||
magic.number.ignore.option=Ignore constants in 'hashCode()' methods
|
||||
method.return.concrete.class.display.name=Method return of concrete class
|
||||
|
||||
+4
-13
@@ -30,8 +30,8 @@ import javax.swing.*;
|
||||
public class MagicNumberInspectionBase extends BaseInspection {
|
||||
@SuppressWarnings("PublicField")
|
||||
public boolean ignoreInHashCode = true;
|
||||
@SuppressWarnings("PublicField")
|
||||
public boolean ignoreInTestCode = false;
|
||||
@SuppressWarnings({"PublicField", "UnusedDeclaration"})
|
||||
public boolean ignoreInTestCode = false; // keep for compatibility
|
||||
@SuppressWarnings("PublicField")
|
||||
public boolean ignoreInAnnotations = true;
|
||||
@SuppressWarnings("PublicField")
|
||||
@@ -53,17 +53,11 @@ public class MagicNumberInspectionBase extends BaseInspection {
|
||||
public JComponent createOptionsPanel() {
|
||||
final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("magic.number.ignore.option"), "ignoreInHashCode");
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("ignore.in.test.code"), "ignoreInTestCode");
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("ignore.in.annotations"),"ignoreInAnnotations");
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("ignore.as.initial.capacity"), "ignoreInitialCapacity");
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean buildQuickFixesOnlyForOnTheFlyErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new MagicNumberVisitor();
|
||||
@@ -87,9 +81,6 @@ public class MagicNumberInspectionBase extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ignoreInTestCode && TestUtils.isInTestCode(expression)) {
|
||||
return;
|
||||
}
|
||||
if (ignoreInAnnotations) {
|
||||
final boolean insideAnnotation = AnnotationUtil.isInsideAnnotation(expression);
|
||||
if (insideAnnotation) {
|
||||
@@ -111,10 +102,10 @@ public class MagicNumberInspectionBase extends BaseInspection {
|
||||
}
|
||||
final PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiPrefixExpression) {
|
||||
registerError(parent);
|
||||
registerError(parent, parent);
|
||||
}
|
||||
else {
|
||||
registerError(expression);
|
||||
registerError(expression, expression);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,13 +15,27 @@
|
||||
*/
|
||||
package com.siyeh.ig.abstraction;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.IntroduceConstantFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MagicNumberInspection extends MagicNumberInspectionBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
return new IntroduceConstantFix();
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final PsiElement context = (PsiElement)infos[0];
|
||||
final InspectionGadgetsFix fix = SuppressForTestsScopeFix.build(this, context);
|
||||
if (fix == null) {
|
||||
return new InspectionGadgetsFix[] {new IntroduceConstantFix()};
|
||||
}
|
||||
return new InspectionGadgetsFix[] {new IntroduceConstantFix(), fix};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean buildQuickFixesOnlyForOnTheFlyErrors() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports "magic numbers", literal numeric constants used without declaration.
|
||||
"Magic numbers" can result in code whose intention is extremely unclear, and may result in errors if a "magic
|
||||
number" is changed in one code location but not another. The numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 0L, 1L, 2L,
|
||||
Reports "magic numbers", which are numeric literals used without being named by a constant declaration.
|
||||
Magic numbers can result in code whose intention is unclear, and may result in errors if a magic
|
||||
number is changed in one code location but not another. The numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 0L, 1L, 2L,
|
||||
0.0, 1.0, 0.0F and 1.0F are not reported by this inspection.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the first checkbox below to disable this inspection within <b>hashCode()</b> methods.
|
||||
<p>
|
||||
Use the second checkbox below to ignore magic numbers in test code.
|
||||
Use the second checkbox below to ignore magic numbers in annotations.
|
||||
<p>
|
||||
Use the third checkbox below to ignore magic numbers in annotations.
|
||||
<p>
|
||||
Use the fourth checkbox below to ignore magic numbers used as initial capacity when constructing <b>Collection</b>, <b>Map</b>,
|
||||
Use the third checkbox below to ignore magic numbers used as initial capacity when constructing <b>Collection</b>, <b>Map</b>,
|
||||
<b>StringBuilder</b> or <b>StringBuffer</b> objects.
|
||||
<p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user