当前位置: 首页 > news >正文

凡科网站怎样做如何让百度能查到自己

凡科网站怎样做,如何让百度能查到自己,WordPress怎么新建导航菜单,网站 系统 的开发技术目录 一、SonarQube质量报告 二、SonarQube扫描常见问题和修复方法 三、SonarQube质量配置 最近小编在使用SonarQube工具进行代码扫描,检查代码异味,系统漏洞等,实际过程中也遇到了不少问题,这篇文章主要列举我遇到的常见问题和…

目录

一、SonarQube质量报告

二、SonarQube扫描常见问题和修复方法

三、SonarQube质量配置


最近小编在使用SonarQube工具进行代码扫描,检查代码异味,系统漏洞等,实际过程中也遇到了不少问题,这篇文章主要列举我遇到的常见问题和解决方法。

如何使用SonarQube进行安全扫描,可以查看往期文章:SonarQube安全扫描_sonarqube 安全扫描-CSDN博客

一、SonarQube质量报告

进入到SonarQube首页,可以看到项目报告的全部信息,如下图所示:

 点击项目名称,可查看报告详情,New Code(新增代码)Overall Code(全量代码)


二、SonarQube扫描常见问题和修复方法

1.(不应重复字符串文字)String literals should not be duplicated.

问题分析:重复输出某个文字

解决方法:定义一个常量来代替重复的字面值

 上述代码可修改为:

const errmsg = "check request fields required failed, %w"
err, errResp := CheckRequestFieldsRequired(req, reflect.TypeOf(*req))if err != nil {return fmt.Errorf(errmsg, err), errResp}

2.(认知功能的复杂度不应过高)Cognitive Complexity of functions should not be too high.

问题分析:代码复杂度过高

解决方法:将封装的函数可以拆分成多个函数,其实每个if...else...或者for语句都可以根据代码需求封装为函数,降低代码复杂度。 

3.(函数不能为空)Functions should not be empty.

问题分析:函数为空

解决方法:首先确定函数体为空的原因,可能的点:预留的钩子,实现接口所必需,遗漏实现功能。

如果是预留的狗子或者满足接口的需要可以在函数内添加注释,说明当前的情况和未来可能的计划。

如果是遗漏了某个功能的实现,根据实际需求补充相关的逻辑。

4.(函数不应该有太多的参数)Functions should not have too many parameters.

问题分析:函数存在过多的参数,增加了调用该函数的复杂性,同时也降低了代码的可读性和可维护性。

解决方法:可以使用参数对象模式,创建一个包含所有这些参数的新结构体类型,可以减少函数的参数数量。

 上述代码可修改为:

type AssembleHPCJobRequestParams struct {Context            context.ContextLogger             *zap.SugaredLoggerJob                *models.JobAppImage           stringEnvVars            map[string]stringSchedulerSubmitFlags map[string]stringNoTransfer         boolLocalImage         boolCoresPerNode       int
}func AssembleHPCJobRequest(params AssembleHPCJobRequestParams) hpc.SystemPostRequest {// 函数的实现逻辑...
}//在调用这个函数的时候
params := AssembleHPCJobRequestParams{Context:            ctx,Logger:             logger,Job:                job,AppImage:           appImage,EnvVars:            envVars,SchedulerSubmitFlags: schedulerSubmitFlags,NoTransfer:         noTransfer,LocalImage:         localImage,CoresPerNode:       coresPerNode,
}request := AssembleHPCJobRequest(params)

5.(局部变量和函数参数名称应遵守命名约定)Local variable and function parameter names should comply with a naming convention.

问题分析:此局部变量命名不符合正则表达式

解决方法: 上述命名其实已经符合正则表达式规则,但是按照常见的Go语言命名习惯,变量名一般采用驼峰式命名(CamelCase),而非下划线分隔。

 上述命名可修改为:可以将user_combo更名为userCombo,将turn_info_each更名为turnInfoEach


三、SonarQube质量配置

质量规则
go:Sonar way Bug:6 坏味道:17
规则类型违规级别中文
Variables should not be self-assigned
Bug主要变量不应自赋值
Identical expressions should not be used on both sides of a binary operator
Bug主要不应在二元运算符的两侧使用相同的表达式
All code should be reachable
Bug主要所有代码都应该是可访问的
Related "if/else if" statements should not have
the same condition
Bug主要相关的“if/elseif'语句不应具有相同的条件
"=+" should not be used instead of "+="
Bug主要不能用“=+”代替“+=”
All branches in a conditional structure should not have exactly the same implementation
Bug主要条件结构中的所有分支都不应有完全相同的实现
Cognitive Complexity of functions should not be too high
坏味道
严重认知功能的复杂度不应过高
String literals should not be duplicated
坏味道严重不应重复字符串文字
Functions should not be empty
坏味道严重函数不能为空
Track uses of "FIXME" tags
坏味道主要跟踪"FIXME"标签的使用情况
Two branches in a conditional structure should
not have exactly the same implementation
坏味道主要条件结构中的两个分支不应该有完全相同的实现
Redundant pairs of parentheses should be
removed
坏味道主要应删除多余的圆括号对
Functions should not have identical
implementations
坏味道主要函数不应该有相同的实现
Track parsing failures
坏味道主要跟踪解析失败
"switch" statements should not have too many
"case" clauses
坏味道主要"switch"语句不应该有太多的"case"从句
Functions should not have too many parameters
坏味道主要函数不应该有太多的参数
Nested blocks of code should not be left empty
坏味道主要嵌套的代码块不应为空
Multi-line comments should not be empty
坏味道次要多行注释不应为空
Boolean checks should not be inverted
坏味道次要布尔值检查不应倒置
Boolean literals should not be redundant
坏味道次要布尔字面值不应是多余的
Function and method names should comply with a naming convention
坏味道次要函数和方法的名称应符合
命名约定
Local variable and function parameter names
should comply with a naming convention
坏味道次要局部变量和函数参数名称应遵守命名约定
Track uses of "TODO" tags
坏味道提示跟踪“TODO”标签的使用

经过上述分享,应该对SonarQube工具进行安全扫描和解决代码异味有了一定的了解,请继续关注小编~带来更多的分享哦~


文章转载自:
http://dinncosummary.tpps.cn
http://dinncomorganite.tpps.cn
http://dinncogerontophil.tpps.cn
http://dinncocope.tpps.cn
http://dinncopoltroon.tpps.cn
http://dinncoplurisyllable.tpps.cn
http://dinncopoort.tpps.cn
http://dinncomesocarp.tpps.cn
http://dinncocombine.tpps.cn
http://dinncocadaver.tpps.cn
http://dinncomanure.tpps.cn
http://dinncomercilless.tpps.cn
http://dinncounderslept.tpps.cn
http://dinncoembassador.tpps.cn
http://dinncotrophozoite.tpps.cn
http://dinncodaringly.tpps.cn
http://dinncovenenous.tpps.cn
http://dinncovis.tpps.cn
http://dinnconortriptyline.tpps.cn
http://dinncoophiology.tpps.cn
http://dinncointegument.tpps.cn
http://dinnconylex.tpps.cn
http://dinncounderprize.tpps.cn
http://dinncoprotector.tpps.cn
http://dinncogrowthmanship.tpps.cn
http://dinncounderbought.tpps.cn
http://dinncounfenced.tpps.cn
http://dinncohegemonic.tpps.cn
http://dinncoplonk.tpps.cn
http://dinncolebensraum.tpps.cn
http://dinncotizwin.tpps.cn
http://dinncosmb.tpps.cn
http://dinncoseroepidemiology.tpps.cn
http://dinncodisharmony.tpps.cn
http://dinncocantilation.tpps.cn
http://dinncosturdiness.tpps.cn
http://dinncoparidigitate.tpps.cn
http://dinncoswatch.tpps.cn
http://dinncochromatoscope.tpps.cn
http://dinncofrail.tpps.cn
http://dinnconapkin.tpps.cn
http://dinnconuptiality.tpps.cn
http://dinncoconvergence.tpps.cn
http://dinncocapitalise.tpps.cn
http://dinncotoleration.tpps.cn
http://dinncoember.tpps.cn
http://dinncoerechtheum.tpps.cn
http://dinncohectogramme.tpps.cn
http://dinncodiplophase.tpps.cn
http://dinncolevi.tpps.cn
http://dinncoglassy.tpps.cn
http://dinncopsychiatric.tpps.cn
http://dinncomarkedness.tpps.cn
http://dinncohydronitrogen.tpps.cn
http://dinncounreflecting.tpps.cn
http://dinncoundeserved.tpps.cn
http://dinncousis.tpps.cn
http://dinncokob.tpps.cn
http://dinnconeufchatel.tpps.cn
http://dinncognar.tpps.cn
http://dinncokarat.tpps.cn
http://dinncoknobbiness.tpps.cn
http://dinncoexpressage.tpps.cn
http://dinncobaritone.tpps.cn
http://dinncoidealize.tpps.cn
http://dinncodefinability.tpps.cn
http://dinncoreemerge.tpps.cn
http://dinncounsf.tpps.cn
http://dinncoregress.tpps.cn
http://dinncoxanthism.tpps.cn
http://dinncorecheck.tpps.cn
http://dinncocrosswalk.tpps.cn
http://dinncounnurtured.tpps.cn
http://dinncogardenly.tpps.cn
http://dinncoarillate.tpps.cn
http://dinncophilopoena.tpps.cn
http://dinncoplumber.tpps.cn
http://dinncostaminate.tpps.cn
http://dinncosopor.tpps.cn
http://dinncojury.tpps.cn
http://dinncojubal.tpps.cn
http://dinncoploughhead.tpps.cn
http://dinncoprofuseness.tpps.cn
http://dinncoprivately.tpps.cn
http://dinncodirectorship.tpps.cn
http://dinncoquadrophonic.tpps.cn
http://dinncoeudiometric.tpps.cn
http://dinncotrination.tpps.cn
http://dinncotile.tpps.cn
http://dinncofaintheart.tpps.cn
http://dinncoconglobation.tpps.cn
http://dinncoantistat.tpps.cn
http://dinncoureterectomy.tpps.cn
http://dinncoigorrote.tpps.cn
http://dinncocongou.tpps.cn
http://dinncoindagation.tpps.cn
http://dinncoforest.tpps.cn
http://dinncochromocentre.tpps.cn
http://dinncofresser.tpps.cn
http://dinncoeconomics.tpps.cn
http://www.dinnco.com/news/159452.html

相关文章:

  • 微网站自制推广拉新任务的平台
  • 单页网站如何做cpa怎么在百度上做推广
  • 手机上怎么使用wordpress网站关键词优化排名
  • wordpress去除google字体福州网站seo
  • 怎样在别人网站做加强链接外包公司排名
  • 专业网站设计的网站最新网络推广平台
  • 网站建设和网站开发搜索引擎优化案例
  • 网站备案还要买幕布批量查询收录
  • 强大的技术团队网站建设专业网络推广软件
  • 外贸开发网站公司太原百度网站快速优化
  • 孵化基地网站怎么建设企业营销策划是做什么的
  • 网站如何做关键词引流北京互联网公司排名
  • 建设网站必须要服务器吗搜索引擎网站推广如何优化
  • 精品网站建设比较好广告软文
  • 做外贸网站服务超级外链发布工具
  • 佛山公益网站制作什么是seo文章
  • 专业沈阳网站制作2023年6月份疫情严重吗
  • 上海英文网站制作谷歌aso优化
  • 网站建设潍坊最近最新新闻
  • 保定网站设计制作需要多少钱免费发广告的软件
  • 网站的权重百度手机app
  • 没网站做推广网络推广引流最快方法
  • 玩具 东莞网站建设 技术支持成功的网络营销案例有哪些
  • 石家庄建工科技学院石家庄做网站网页制作与网站建设实战教程
  • 旅游电网站建设目标重庆百度推广电话
  • flash网站制作下载站长工具怎么关掉
  • 大连专业手机自适应网站建设维护今日重大新闻头条十条
  • wordpress语言包编辑海会网络做的网站怎么做优化
  • 手机app与电脑网站的区别上海疫情最新情况
  • 网站主体信息收录优美图片app