Create rule S6925 (#3634)
This commit is contained in:
parent
ff7d018f38
commit
d036b082d1
2
rules/S6925/metadata.json
Normal file
2
rules/S6925/metadata.json
Normal file
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
24
rules/S6925/python/metadata.json
Normal file
24
rules/S6925/python/metadata.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"title": "The \"validate_indices\" argument should not be set for \"tf.gather\" function call",
|
||||
"type": "CODE_SMELL",
|
||||
"status": "ready",
|
||||
"remediation": {
|
||||
"func": "Constant\/Issue",
|
||||
"constantCost": "5min"
|
||||
},
|
||||
"tags": [
|
||||
],
|
||||
"defaultSeverity": "Major",
|
||||
"ruleSpecification": "RSPEC-6925",
|
||||
"sqKey": "S6925",
|
||||
"scope": "All",
|
||||
"defaultQualityProfiles": ["Sonar way"],
|
||||
"quickfix": "unknown",
|
||||
"code": {
|
||||
"impacts": {
|
||||
"MAINTAINABILITY": "HIGH",
|
||||
"RELIABILITY": "MEDIUM"
|
||||
},
|
||||
"attribute": "CONVENTIONAL"
|
||||
}
|
||||
}
|
34
rules/S6925/python/rule.adoc
Normal file
34
rules/S6925/python/rule.adoc
Normal file
@ -0,0 +1,34 @@
|
||||
This rule raises an issue when the `validate_indices` argument is set for `tf.gather ` function call.
|
||||
|
||||
== Why is this an issue?
|
||||
The `tf.gather` function allows you to gather slices from a tensor along a specified axis according to the indices provided.
|
||||
The `validate_indices` argument is deprecated and setting its value has no effect. Indices are always validated on CPU and never validated on GPU.
|
||||
|
||||
== How to fix it
|
||||
|
||||
=== Code examples
|
||||
|
||||
==== Noncompliant code example
|
||||
|
||||
[source,python,diff-id=1,diff-type=noncompliant]
|
||||
----
|
||||
import tensorflow as tf
|
||||
|
||||
x = tf.constant([[1, 2], [3, 4]])
|
||||
y = tf.gather(x, [1], validate_indices=True) # Noncompliant: validate_indices is deprecated
|
||||
----
|
||||
|
||||
==== Compliant solution
|
||||
|
||||
[source,python,diff-id=1,diff-type=compliant]
|
||||
----
|
||||
import tensorflow as tf
|
||||
|
||||
x = tf.constant([[1, 2], [3, 4]])
|
||||
y = tf.gather(x, [1]) # OK
|
||||
----
|
||||
|
||||
|
||||
== Resources
|
||||
=== Documentation
|
||||
* Tensorflow documentation - https://www.tensorflow.org/api_docs/python/tf/gather[tf.gather]
|
Loading…
x
Reference in New Issue
Block a user