Git Product home page Git Product logo

analysisutil's Introduction

analysisutil

PkgGoDev

Utilities for x/tools/go/analysis package.

analysisutil's People

Contributors

himer avatar masibw avatar matts966 avatar tenntenn avatar tetsuzawa avatar zchee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

analysisutil's Issues

call: CalledFrom does not work for the function which has multiple return values

What

I am trying to use static analysis to detect functions that do not call "Close". But I found an issue in CalledFrom function.

CalledFrom function can correctly detects that the case (1) is NG.

case (1):

func f() {
	client.ReadOnlyTransaction()   // want "NG"
}

However, in the case (2), the function cannot correctly detects that it is NG.

case (2):

func f() {
	os.Open("xxx") //want "NG"
}

Why

In the CalledFrom function, identical function is called to compare receiver (types.Pointer type) and the return value of called funtion (eg. os.Open()).

In the case (1), client.ReadOnlyTransaction() returns only one value, so the type of return value is (types.Pointer).

However, in the case (2), os.Open() returns two values, so the type of return value is (types.Tuple).

Because of them, CalledFrom cannot correctly detects the case (2) is NG.

CalledFrom does not match sqlrowsutil.CalledFrom behavior

I was recently trying to use analysisutil.CalledFrom instead of the example in sqlrowsutil. However this does not work as expected. analysisutil seems to be close, but not the exact behavior as sqlrowsutil. Is this expected? The godocs and signatures exactly match, so the assumption is their behavior would match as well.

https://github.com/gostaticanalysis/sqlrows/blob/master/sqlrowsutil/util.go#L199
https://github.com/gostaticanalysis/analysisutil/blob/v0.7.1/call.go#L397

call: CalledFrom does not work for embedded type

type res struct{}
func newRes() *res { return &res{} }
func (r *res) close() {}
func f() {
	r := newRes() // want `NG` it works
	_ = r
}

// embedded type
type res2 struct{ *res }
func newRes2() *res2 { return &res2{newRes()}}
func g() {
	r := newRes2() // want `NG` but does not work
	_ = r
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.