Commit 56afdbb9 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '346031-Fix-GraphQL/FieldMethod-offense' into 'master'

Fix GraphQL/FieldMethod offense (Part 1/2)

See merge request gitlab-org/gitlab!76020
parents 106795c6 ff8b0e5b
--- ---
GraphQL/FieldMethod: GraphQL/FieldMethod:
Exclude: Exclude:
- app/graphql/types/ci/job_type.rb
- app/graphql/types/merge_request_type.rb
- app/graphql/types/metrics/dashboards/annotation_type.rb
- app/graphql/types/packages/package_details_type.rb - app/graphql/types/packages/package_details_type.rb
- app/graphql/types/project_type.rb
...@@ -61,7 +61,7 @@ module Types ...@@ -61,7 +61,7 @@ module Types
field :coverage, GraphQL::Types::Float, null: true, field :coverage, GraphQL::Types::Float, null: true,
description: 'Coverage level of the job.' description: 'Coverage level of the job.'
field :created_by_tag, GraphQL::Types::Boolean, null: false, field :created_by_tag, GraphQL::Types::Boolean, null: false,
description: 'Whether the job was created by a tag.' description: 'Whether the job was created by a tag.', method: :tag?
field :detailed_status, Types::Ci::DetailedStatusType, null: true, field :detailed_status, Types::Ci::DetailedStatusType, null: true,
description: 'Detailed status of the job.' description: 'Detailed status of the job.'
field :downstream_pipeline, Types::Ci::PipelineType, null: true, field :downstream_pipeline, Types::Ci::PipelineType, null: true,
...@@ -173,10 +173,6 @@ module Types ...@@ -173,10 +173,6 @@ module Types
object&.coverage object&.coverage
end end
def created_by_tag
object.tag?
end
def manual_job def manual_job
object.try(:action?) object.try(:action?)
end end
......
...@@ -179,7 +179,7 @@ module Types ...@@ -179,7 +179,7 @@ module Types
description: 'Total time reported as spent on the merge request.' description: 'Total time reported as spent on the merge request.'
field :approved_by, Types::UserType.connection_type, null: true, field :approved_by, Types::UserType.connection_type, null: true,
description: 'Users who approved the merge request.' description: 'Users who approved the merge request.', method: :approved_by_users
field :auto_merge_strategy, GraphQL::Types::String, null: true, field :auto_merge_strategy, GraphQL::Types::String, null: true,
description: 'Selected auto merge strategy.' description: 'Selected auto merge strategy.'
field :available_auto_merge_strategies, [GraphQL::Types::String], null: true, calls_gitaly: true, field :available_auto_merge_strategies, [GraphQL::Types::String], null: true, calls_gitaly: true,
...@@ -208,10 +208,6 @@ module Types ...@@ -208,10 +208,6 @@ module Types
markdown_field :title_html, null: true markdown_field :title_html, null: true
markdown_field :description_html, null: true markdown_field :description_html, null: true
def approved_by
object.approved_by_users
end
def user_notes_count def user_notes_count
BatchLoader::GraphQL.for(object.id).batch(key: :merge_request_user_notes_count) do |ids, loader, args| BatchLoader::GraphQL.for(object.id).batch(key: :merge_request_user_notes_count) do |ids, loader, args|
counts = Note.count_for_collection(ids, 'MergeRequest').index_by(&:noteable_id) counts = Note.count_for_collection(ids, 'MergeRequest').index_by(&:noteable_id)
......
...@@ -14,17 +14,14 @@ module Types ...@@ -14,17 +14,14 @@ module Types
description: 'ID of the annotation.' description: 'ID of the annotation.'
field :panel_id, GraphQL::Types::String, null: true, field :panel_id, GraphQL::Types::String, null: true,
description: 'ID of a dashboard panel to which the annotation should be scoped.' description: 'ID of a dashboard panel to which the annotation should be scoped.',
method: :panel_xid
field :starting_at, Types::TimeType, null: true, field :starting_at, Types::TimeType, null: true,
description: 'Timestamp marking start of annotated time span.' description: 'Timestamp marking start of annotated time span.'
field :ending_at, Types::TimeType, null: true, field :ending_at, Types::TimeType, null: true,
description: 'Timestamp marking end of annotated time span.' description: 'Timestamp marking end of annotated time span.'
def panel_id
object.panel_xid
end
end end
end end
end end
......
...@@ -32,10 +32,10 @@ module Types ...@@ -32,10 +32,10 @@ module Types
field :tag_list, GraphQL::Types::String, null: true, field :tag_list, GraphQL::Types::String, null: true,
deprecated: { reason: 'Use `topics`', milestone: '13.12' }, deprecated: { reason: 'Use `topics`', milestone: '13.12' },
description: 'List of project topics (not Git tags).' description: 'List of project topics (not Git tags).', method: :topic_list
field :topics, [GraphQL::Types::String], null: true, field :topics, [GraphQL::Types::String], null: true,
description: 'List of project topics.' description: 'List of project topics.', method: :topic_list
field :http_url_to_repo, GraphQL::Types::String, null: true, field :http_url_to_repo, GraphQL::Types::String, null: true,
description: 'URL to connect to the project via HTTPS.' description: 'URL to connect to the project via HTTPS.'
...@@ -461,14 +461,6 @@ module Types ...@@ -461,14 +461,6 @@ module Types
object.service_desk_address object.service_desk_address
end end
def tag_list
object.topic_list
end
def topics
object.topic_list
end
private private
def project def project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment