forked from Gitlink/forgeplus
sonar 转发接口
This commit is contained in:
parent
9c84856f99
commit
c98c7d5ac5
1
Gemfile
1
Gemfile
|
@ -70,6 +70,7 @@ group :development do
|
|||
gem 'web-console', '>= 3.3.0'
|
||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||
gem 'spring'
|
||||
gem 'pry-rails'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
gem "annotate", "~> 2.6.0"
|
||||
end
|
||||
|
|
|
@ -107,6 +107,7 @@ GEM
|
|||
archive-zip (~> 0.10)
|
||||
nokogiri (~> 1.8)
|
||||
chunky_png (1.3.11)
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.1.6)
|
||||
connection_pool (2.2.2)
|
||||
crass (1.0.6)
|
||||
|
@ -255,6 +256,11 @@ GEM
|
|||
popper_js (1.16.0)
|
||||
powerpack (0.1.2)
|
||||
prettier (0.18.2)
|
||||
pry (0.12.2)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.9.0)
|
||||
pry-rails (0.3.9)
|
||||
pry (>= 0.10.4)
|
||||
public_suffix (4.0.3)
|
||||
puma (5.6.8)
|
||||
nio4r (~> 2.0)
|
||||
|
@ -526,6 +532,7 @@ DEPENDENCIES
|
|||
parallel (~> 1.19, >= 1.19.1)
|
||||
pdfkit
|
||||
prettier
|
||||
pry-rails
|
||||
puma (~> 5.6.5)
|
||||
rack-cors
|
||||
rails (~> 5.2.0)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the api/v1/sonarqubes controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -9,10 +9,6 @@ class Api::V1::ProjectsController < Api::V1::BaseController
|
|||
@result_object = Api::V1::Projects::GetService.call(@project, current_user.gitea_token)
|
||||
end
|
||||
|
||||
def sonar_search
|
||||
data = Sonarqube.client.get("/api/issues/search", { components:"#{@project.owner.login}-#{@project.identifier}" })
|
||||
render_ok data
|
||||
end
|
||||
|
||||
def compare
|
||||
@result_object = Api::V1::Projects::CompareService.call(@project, params[:from], params[:to], current_user&.gitea_token)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
class Api::V1::SonarqubesController < Api::V1::BaseController
|
||||
def issues_search
|
||||
params_data = {
|
||||
components: 'kingchanx-fluid-cloudnative_fluid',
|
||||
s: 'FILE_LINE',
|
||||
impactSoftwareQualities: 'SECURITY',
|
||||
issueStatuses: 'CONFIRMED%2COPEN',
|
||||
ps: 100,
|
||||
facets: 'cleanCodeAttributeCategories%2CimpactSoftwareQualities%2CcodeVariants&',
|
||||
additionalFields: '_all',
|
||||
timeZone: 'Asia%2FShanghai'
|
||||
}
|
||||
data = Sonarqube.client.get('/api/issues/search', params_data)
|
||||
render_ok data
|
||||
end
|
||||
|
||||
def ce_component
|
||||
params_data = {
|
||||
components: 'kingchanx-fluid-cloudnative_fluid',
|
||||
}
|
||||
data = Sonarqube.client.get('/api/ce/component', params_data)
|
||||
render_ok data
|
||||
end
|
||||
|
||||
def sources_issue_snippet
|
||||
params_data = {
|
||||
issueKey: '93f87856-d71e-44f6-93b6-f9a6d54ff488'
|
||||
}
|
||||
data = Sonarqube.client.get('/api/sources/issue_snippets', params_data)
|
||||
render_ok data
|
||||
end
|
||||
|
||||
def rules_show
|
||||
params_data = {
|
||||
key: 'kubernetes%3AS6865'
|
||||
}
|
||||
data = Sonarqube.client.get('/api/rules/show', params_data)
|
||||
render_ok data
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Api::V1::SonarqubesHelper
|
||||
end
|
|
@ -76,7 +76,12 @@ defaults format: :json do
|
|||
collection do
|
||||
get :compare
|
||||
get :blame
|
||||
get :sonar_search
|
||||
|
||||
end
|
||||
end
|
||||
resource :sonarqubes, only: [:index] do
|
||||
collection do
|
||||
get :search
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::V1::SonarqubesController, type: :controller do
|
||||
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Api::V1::SonarqubesHelper. For example:
|
||||
#
|
||||
# describe Api::V1::SonarqubesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Api::V1::SonarqubesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue