An approach to automatically mine program code repositories in order to support software reuse is proposed in this paper. Code attributes and structural relationships are used to find and rank the potential elements based on a given query. Static program analysis is used to allow a filtered mining through three well-established metrics that have a direct impact on code quality. The approach has been empirically evaluated and the results obtained were promising.