Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.SourceLineAnnotation


            fallthroughDistance = 0;
            potentiallyDeadStoresFromBeforeFallthrough = (BitSet) potentiallyDeadStores.clone();
            potentiallyDeadFieldsFromBeforeFallthrough = new HashSet<XField>(potentiallyDeadFields);
            if (!hasFallThruComment(lastPC + 1, getPC() - 1)) {
                if (!isDefaultOffset) {
                    SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(
                            getClassContext(), this, lastPC, getPC());
                    found.add(sourceLineAnnotation);
                } else if ( getPC() >= biggestJumpTarget) {
                    SourceLineAnnotation sourceLineAnnotation = switchHdlr.getCurrentSwitchStatement(this);
                    if (DEBUG) {
                        System.out.printf("Found fallthrough to default offset at %d (BJT is %d)%n", getPC(), biggestJumpTarget);
                    }

                    foundSwitchNoDefault(sourceLineAnnotation);
View Full Code Here


    private boolean hasFallThruComment(int startPC, int endPC) {
        if (LOOK_IN_SOURCE_FOR_FALLTHRU_COMMENT) {
            BufferedReader r = null;
            try {
                SourceLineAnnotation srcLine = SourceLineAnnotation.fromVisitedInstructionRange(this, lastPC, getPC());
                SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder();
                SourceFile sourceFile = sourceFinder.findSourceFile(srcLine.getPackageName(), srcLine.getSourceFile());

                int startLine = srcLine.getStartLine();
                int numLines = srcLine.getEndLine() - startLine - 1;
                if (numLines <= 0) {
                    return false;
                }
                r = UTF8.bufferedReader(sourceFile.getInputStream());
                for (int i = 0; i < startLine; i++) {
View Full Code Here

    @Override
    public void visit(LocalVariable obj) {
        if (isReservedName(obj.getName())) {
            LocalVariableAnnotation var = new LocalVariableAnnotation(obj.getName(), obj.getIndex(), obj.getStartPC());
            SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, obj.getStartPC());
            BugInstance bug = new BugInstance(this, "NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER", NORMAL_PRIORITY)
            .addClassAndMethod(this).add(var).add(source);
            bugReporter.reportBug(bug);
        }
    }
View Full Code Here

                    if (false) {
                        System.out.println(getFullyQualifiedMethodName());
                        System.out.println(first + " ... " + endOfFirstSegment + " : " + OPCODE_NAMES[opcodeAtEndOfFirst]);
                        System.out.println(second + " ... " + endOfSecondSegment + " : " + OPCODE_NAMES[opcodeAtEndOfSecond]);
                    }
                    SourceLineAnnotation firstSourceLine = SourceLineAnnotation.fromVisitedInstructionRange(getClassContext(),
                            this, first, endOfFirstSegment - 1);
                    SourceLineAnnotation secondSourceLine = SourceLineAnnotation.fromVisitedInstructionRange(getClassContext(),
                            this, second, endOfSecondSegment - 1);

                    int priority = HIGH_PRIORITY;
                    if (firstSourceLine.getStartLine() == -1 || firstSourceLine.getStartLine() != secondSourceLine.getEndLine()) {
                        priority++;
                    }
                    if (stack.isJumpTarget(second)) {
                        priority++;
                    }
View Full Code Here

                if (isSerializable < isRemote) {
                    isSerializable = isRemote;
                }


                SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext,
                        methodGen, sourceFile, handle);

                bugReporter.reportBug(new BugInstance(this, "DMI_NONSERIALIZABLE_OBJECT_WRITTEN",
                        isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
                .addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE)
View Full Code Here

            break;

        case IFEQ:
        case IFNE:
            if (state == SAW_COMP) {
                SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this,
                        getPC());
                if (sourceLineAnnotation != null) {
                    found.add(sourceLineAnnotation);
                }
            }
View Full Code Here

                }
            }
            if (applySuppressionSpecified && applySuppression && suppressionFilter.match(bug)) {
                return false;
            }
            SourceLineAnnotation primarySourceLineAnnotation = bug.getPrimarySourceLineAnnotation();

            if (knownSourceSpecified) {
                if (primarySourceLineAnnotation.isUnknown() == knownSource) {
                    return false;
                }
            }
            if (withSourceSpecified) {
                if (sourceSearcher.findSource(primarySourceLineAnnotation) != withSource) {
View Full Code Here

        origCollection = new SortedBugCollection();
        origCollection.readXML(args[0]);
        SourceFinder sourceFinder = new SourceFinder(origCollection.getProject());

        for (BugInstance b : origCollection) {
            SourceLineAnnotation s = b.getPrimarySourceLineAnnotation();
            if (!s.isSourceFileKnown()) {
                continue;
            }
            if (!sourceFinder.hasSourceFile(s)) {
                continue;
            }
View Full Code Here

        Map<String, Set<String>> missingFiles = new HashMap<String, Set<String>>();
        if (!commandLine.searchSourcePaths.isEmpty()) {
            sourceSearcher = new SourceSearcher(project);
            for (BugInstance bug : origCollection.getCollection()) {
                SourceLineAnnotation src = bug.getPrimarySourceLineAnnotation();
                if (!sourceSearcher.sourceNotFound.contains(src.getClassName()) && !sourceSearcher.findSource(src)) {
                    Set<String> paths = missingFiles.get(src.getSourceFile());
                    if (paths == null) {
                        paths = new HashSet<String>();
                        missingFiles.put(src.getSourceFile(), paths);
                    }
                    String fullPath = fullPath(src);
                    // System.out.println("Missing " + fullPath);
                    paths.add(fullPath);
                }
View Full Code Here

            close(out);
        }
    }

    private void copySourceForAnnotation(BugAnnotation ann) {
        SourceLineAnnotation sourceAnnotation;
        if (ann instanceof BugAnnotationWithSourceLines) {
            sourceAnnotation = ((BugAnnotationWithSourceLines) ann).getSourceLines();
        } else if (ann instanceof SourceLineAnnotation) {
            sourceAnnotation = (SourceLineAnnotation) ann;
        } else {
            return;
        }
        if (sourceAnnotation == null) {
            return;
        }
        if (sourceAnnotation.isUnknown()) {
            return;
        }

        String fullName = SourceFinder.getPlatformName(sourceAnnotation);
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.SourceLineAnnotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.