[ 
https://issues.apache.org/jira/browse/YUNIKORN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848209#comment-17848209
 ] 

Chia-Ping Tsai commented on YUNIKORN-182:
-----------------------------------------

Any updates? the k8shime has following warnings:

{quote}
WARN [config_reader] The configuration option `linters.govet.check-shadowing` 
is deprecated. Please enable `shadow` instead, if you are not using 
`enable-all`. 
pkg/admission/conf/am_conf.go:121:39: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandler` is not checked 
(errcheck)
        configMaps.Informer().AddEventHandler(&configMapUpdateHandler{conf: 
acc})
                                             ^
pkg/cmd/shim/main.go:25: File is not `goimports`-ed with -local 
github.com/apache/yunikorn (goimports)

pkg/plugin/predicates/predicate_manager_test.go:360: Function 
'TestPodFitsSelector' is too long (694 > 120) (funlen)
func TestPodFitsSelector(t *testing.T) {
pkg/plugin/predicates/predicate_manager_test.go:1205: Function 
'TestInterPodAffinity' is too long (944 > 120) (funlen)
func TestInterPodAffinity(t *testing.T) {
pkg/plugin/predicates/predicate_manager_test.go:228:14: G109: Potential Integer 
overflow made by strconv.Atoi result conversion to int16/32 (gosec)
                        HostPort: int32(hostPort),
                                  ^
test/e2e/gang_scheduling/gang_scheduling_test.go:711:4: shadow: declaration of 
"err" shadows declaration at line 696 (govet)
                        err := kClient.DeleteConfigMap(testConfigmap.Name, ns)
                        ^
test/e2e/gang_scheduling/gang_scheduling_test.go:715:18: shadow: declaration of 
"err" shadows declaration at line 696 (govet)
                testConfigmap, err := kClient.CreateConfigMap(testConfigmap, ns)
                               ^
test/e2e/framework/helpers/k8s/k8s_utils.go:719:46: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandler` is not checked 
(errcheck)
        configMapInformer.Informer().AddEventHandler(eventHandler)
                                                    ^
pkg/common/resource_test.go:150: Function 'TestParsePodResource' has too many 
statements (91 > 80) (funlen)
func TestParsePodResource(t *testing.T) {
pkg/common/si_helper_test.go:71:13: string `pod-resource-test-00001` has 3 
occurrences, make it a constant (goconst)
        podName := "pod-resource-test-00001"
                   ^
pkg/common/si_helper_test.go:72:15: string `important` has 3 occurrences, make 
it a constant (goconst)
        namespace := "important"
                     ^
test/e2e/framework/helpers/common/utils.go:105:18: G404: Use of weak random 
number generator (math/rand instead of crypto/rand) (gosec)
                b[i] = letters[rand.Intn(len(letters))]
                               ^
pkg/cache/external/scheduler_cache_test.go:310: Function 
'TestGetNodesInfoPodsWithAffinity' is too long (155 > 120) (funlen)
func TestGetNodesInfoPodsWithAffinity(t *testing.T) {
pkg/client/apifactory.go:177:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/apifactory.go:180:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/apifactory.go:183:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/apifactory.go:186:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/apifactory.go:189:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/apifactory.go:192:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/apifactory.go:195:35: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandlerWithResyncPeriod` 
is not checked (errcheck)
                        AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
                                                       ^
pkg/client/kubeclient.go:141: pkg/client/kubeclient.go:141: Line contains 
TODO/BUG/FIXME: "TODO make this configurable for pods" (godox)
        // TODO make this configurable for pods
test/e2e/spark_jobs_scheduling/spark_jobs_scheduling_test.go:67:8: shadow: 
declaration of "err" shadows declaration at line 46 (govet)
                ns1, err := kClient.CreateNamespace(sparkNS, nil)
                     ^
test/e2e/spark_jobs_scheduling/spark_jobs_scheduling_test.go:97:3: shadow: 
declaration of "err" shadows declaration at line 46 (govet)
                err := exec.Command(
                ^
test/e2e/spark_jobs_scheduling/spark_jobs_scheduling_test.go:56:3: ineffectual 
assignment to sparkHome (ineffassign)
                sparkHome = "/usr/local/"
                ^
pkg/cmd/admissioncontroller/main.go:143:15: G112: Potential Slowloris Attack 
because ReadHeaderTimeout is not configured in the http.Server (gosec)
        wh.server = &http.Server{
                Addr: fmt.Sprintf(":%v", wh.port),
                TLSConfig: &tls.Config{
                        MinVersion:   tls.VersionTLS12,           // No SSL, 
TLS 1.0 or TLS 1.1 support
                        NextProtos:   []string{"h2", "http/1.1"}, // prefer 
HTTP/2 over HTTP/1.1
                        CipherSuites: wh.getCipherSuites(),       // limit 
cipher suite to secure ones
                        Certificates: []tls.Certificate{*certs},
                },
                Handler: mux,
        }
pkg/admission/namespace_cache.go:61:40: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandler` is not checked 
(errcheck)
                
namespaces.Informer().AddEventHandler(&namespaceUpdateHandler{cache: nsc})
                                                     ^
pkg/admission/priority_class_cache.go:44:45: Error return value of 
`(k8s.io/client-go/tools/cache.SharedInformer).AddEventHandler` is not checked 
(errcheck)
                
priorityClasses.Informer().AddEventHandler(&priorityClassUpdateHandler{cache: 
pcc})
                                                          ^
pkg/shim/scheduler_test.go:42:16: string `
partitions:
  - name: default
    queues:
      - name: root
        submitacl: "*"
        queues:
          - name: a
            resources:
              guaranteed:
                memory: 100000000
                vcore: 10
              max:
                memory: 150000000
                vcore: 20
` has 3 occurrences, make it a constant (goconst)
        configData := `
                      ^
pkg/shim/scheduler_mock_test.go:165:26: func 
`(*MockScheduler).removeApplication` is unused (unused)
func (fc *MockScheduler) removeApplication(appId string) error {
                         ^
pkg/cache/task_state.go:317: Function 'newTaskState' is too long (124 > 120) 
(funlen)
func newTaskState() *fsm.FSM {
pkg/cache/application_test.go:752: Function 'TestTryReservePostRestart' is too 
long (123 > 120) (funlen)
func TestTryReservePostRestart(t *testing.T) {
pkg/cache/context_test.go:858: Function 'TestRecoverTask' is too long (138 > 
120) (funlen)
func TestRecoverTask(t *testing.T) {
pkg/cache/context_test.go:1484: Function 'TestAddApplicationsWithTags' is too 
long (145 > 120) (funlen)
func TestAddApplicationsWithTags(t *testing.T) {
pkg/cache/task_test.go:493: Function 'TestHandleSubmitTaskEvent' is too long 
(123 > 120) (funlen)
func TestHandleSubmitTaskEvent(t *testing.T) {
pkg/cache/application_test.go:562:13: string `task02` has 3 occurrences, make 
it a constant (goconst)
        taskID2 := "task02"
                   ^
pkg/cache/task_state_test.go:2: File is not `gofmt`-ed with `-s` (gofmt)
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
pkg/cache/task_state_test.go:10: File is not `goimports`-ed with -local 
github.com/apache/yunikorn (goimports)
     http://www.apache.org/licenses/LICENSE-2.0
pkg/cache/context.go:788:8: ineffectual assignment to allBound (ineffassign)
                        var allBound = true
                            ^
make: *** [Makefile:291:lint] 錯誤 1
{quote}

1. we can add log for those unchecked error
2. fix the license header (add new line)
3. add  `min-occurrences = 5` to increase the threshold
4. remove unused variable/functions
5. fix the long function (this may be addressed by different PR)

Except for (5), other fixes should be included in single PR.

> fix lint issues
> ---------------
>
>                 Key: YUNIKORN-182
>                 URL: https://issues.apache.org/jira/browse/YUNIKORN-182
>             Project: Apache YuniKorn
>          Issue Type: Task
>          Components: build
>            Reporter: Wilfred Spiegelenburg
>            Assignee: Tarun Parimi
>            Priority: Minor
>
> When we added the lint test most major issues were fixed. There are still a 
> lot of issues specially in tests that need to be fixed.
> This is a container Jira to track that work on both the k8shim as the core 
> repos.
> Work should be split into multiple parts (per linter?)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@yunikorn.apache.org
For additional commands, e-mail: issues-h...@yunikorn.apache.org

Reply via email to