Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced functionality to improve developer experience by identifying… #7494

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions analyzer/src/main/kotlin/AnalyzerResultBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,48 @@
private val issues = mutableMapOf<Identifier, List<Issue>>()
private val dependencyGraphs = mutableMapOf<String, DependencyGraph>()

private fun getPaths(
dependencyGraph: DependencyGraph?,
identifier: Identifier,
): MutableList<Identifier> {

Check warning

Code scanning / detekt

Rule to mandate/forbid trailing commas at declaration sites Warning

Unnecessary trailing comma before ")"

val packageName = dependencyGraph!!.packages.find { it == identifier } // gets the whole Identifier of the duplicate

Check warning

Code scanning / detekt

Reports methods that have an empty first line. Warning

First line in a method block should not be empty

Check warning

Code scanning / detekt

Reports multiple space usages Warning

Unnecessary long whitespace

Check warning

Code scanning / detekt

Reports multiple space usages Warning

Unnecessary long whitespace

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.
val packageNameId = dependencyGraph.packages.indexOf(packageName) // gets the id from the duplicate
var packageList: MutableList<Identifier> = mutableListOf<Identifier>()

Check notice on line 54 in analyzer/src/main/kotlin/AnalyzerResultBuilder.kt

View workflow job for this annotation

GitHub Actions / qodana-scan

Unnecessary type argument

Remove explicit type arguments
packageList = findSource(packageNameId,dependencyGraph,packageList)

Check warning

Code scanning / detekt

Reports spaces around commas Warning

Missing spacing after ","

Check warning

Code scanning / detekt

Reports spaces around commas Warning

Missing spacing after ","
return packageList
}

Check warning

Code scanning / detekt

Format signature to be single when possible, multiple lines otherwise. Warning

No whitespace expected between opening parenthesis and first parameter name

Check warning

Code scanning / detekt

Format signature to be single when possible, multiple lines otherwise. Warning

Single whitespace expected before parameter

Check warning

Code scanning / detekt

Format signature to be single when possible, multiple lines otherwise. Warning

No whitespace expected between last parameter and closing parenthesis

private fun findSource(
pkgId: Int,
dependencyGraph: DependencyGraph,
packageList: MutableList<Identifier>
): MutableList<Identifier> {
packageList.add(dependencyGraph.packages[pkgId])
try {

val dependencyKid = dependencyGraph.dependencies.map { dependency -> dependency.value.find { it.pkg == pkgId } }.filterNotNull()

Check warning

Code scanning / detekt

Reports methods that have an empty first line. Warning

First line in a method block should not be empty

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline after "{"

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.
val parent = dependencyGraph.dependencies.filterValues { it.contains(dependencyKid[0]) }.keys.iterator().next().pkg

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.

findSource(parent, dependencyGraph, packageList)

} catch (inEx: IndexOutOfBoundsException) {

Check warning

Code scanning / detekt

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

Check warning

Code scanning / detekt

The caught exception is swallowed. The original exception could be lost. Warning

The caught exception is swallowed. The original exception could be lost.

Check warning

Code scanning / detekt

Detects blank lines before rbraces Warning

Unexpected blank line(s) before "}"
return packageList
}
return packageList
}

fun build(excludes: Excludes = Excludes.EMPTY): AnalyzerResult {
val duplicates = (projects.map { it.toPackage() } + packages).getDuplicates { it.id }
require(duplicates.isEmpty()) {
val reverseDependencyTree = mutableListOf<Any>()
duplicates.forEach() {

Check notice on line 82 in analyzer/src/main/kotlin/AnalyzerResultBuilder.kt

View workflow job for this annotation

GitHub Actions / qodana-scan

Unnecessary parentheses in function call with lambda

Unnecessary parentheses in function call with lambda

Check warning

Code scanning / detekt

Ensures there are no unnecessary parentheses before a trailing lambda Warning

Empty parentheses in function call followed by lambda are unnecessary
val dependencyPaths = getPaths(dependencyGraphs[it.key.type],it.key)

Check warning

Code scanning / detekt

Reports spaces around commas Warning

Missing spacing after ","

Check warning

Code scanning / detekt

Reports multiple space usages Warning

Unnecessary long whitespace
reverseDependencyTree.add(dependencyPaths)
}
"Unable to create the AnalyzerResult as it contains packages and projects with the same ids: " +
duplicates.values
}
duplicates.values + " Here are the complete paths for each duplicate dependency: " + reverseDependencyTree

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.
}

Check warning

Code scanning / detekt

Reports mis-indented code Warning

Unexpected indentation (4) (should be 8)

return AnalyzerResult(projects, packages, issues, dependencyGraphs)
.convertToDependencyGraph(excludes)
Expand Down
Loading