Skip to content

Commit

Permalink
fix check_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii-ldv committed Feb 7, 2022
1 parent 10a524c commit d26f5d6
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->
raise Exception(f"Custom query should not contain {CustomQuery.cursor_field}")

req_q = CustomQuery.insert_segments_date_expr(query, "1980-01-01", "1980-01-01")
google_api.send_request(req_q)
google_api.send_request(req_q, google_api.customer_ids[0])
return True, None
except GoogleAdsException as error:
return False, f"Unable to connect to Google Ads API with the provided credentials - {repr(error.failure)}"
Expand Down

1 comment on commit d26f5d6

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarQube Report

SonarQube report for Airbyte Connectors Source Google Ads(#10150)

Measures

Name Value Name Value Name Value
Bugs 1 Duplicated Lines (%) 0.0 Lines to Cover 28
Security Rating A Coverage 21.4 Reliability Rating A
Quality Gate Status ERROR Code Smells 3 Lines of Code 1247
Duplicated Blocks 0 Vulnerabilities 0 Blocker Issues 2
Critical Issues 11 Major Issues 14 Minor Issues 48

Detected Issues

Rule File Description Message
python:mypy_index (MINOR) source_google_ads/streams.py:175 Check indexing operations Unsupported target for indexed assignment ("Optional[Mapping[str, Any]]") . Code line: stream_slice["start_date"] = state.get(self._custo...
python:mypy_index (MINOR) source_google_ads/google_ads.py:37 Check indexing operations Unsupported target for indexed assignment ("Mapping[str, Any]") . Code line: credentials["use_proto_plus"] = True
python:mypy_assignment (MINOR) source_google_ads/streams.py:119 Check that assigned value is compatible with target Incompatible types in assignment (expression has type "str", variable has type "None") . Code line: self._customer_id = customer_id
python:isort_need_format (MINOR) source_google_ads/streams.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:mypy_attr_defined (MINOR) source_google_ads/streams.py:194 Check that attribute exists Module has no attribute "parse" . Code line: date_in_current_stream = pendulum.parse(stream_state)
python:isort_need_format (MINOR) integration_tests/test_incremental.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:S1192 (CRITICAL) integration_tests/test_incremental.py:35 String literals should not be duplicated Define a constant instead of duplicating this literal "segments.date" 13 times.
python:isort_need_format (MINOR) source_google_ads/google_ads.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:mypy_index (MINOR) source_google_ads/streams.py Check indexing operations Unsupported target for indexed assignment ("Optional[Mapping[str, Any]]") . Code line: stream_slice["start_date"] = state.get(self.cursor...
python:mypy_valid_type (MINOR) source_google_ads/streams.py:17 Check that type (annotation) is valid Function is missing a type annotation [no-untyped-def] def parse_dates(stream_slice):
python:mypy_no_untyped_def (MINOR) source_google_ads/streams.py:23 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def get_date_params(start_date: str, time_zone=None, range_days: int =...
flake8:E501 (MAJOR) source_google_ads/streams.py:26 line too long (82 > 79 characters) line too long (143 > 140 characters)
python:mypy_attr_defined (MINOR) source_google_ads/streams.py:32 Check that attribute exists Module has no attribute "parse" . Code line: start_date = pendulum.parse(start_date)
python:mypy_override (MINOR) source_google_ads/streams.py:143 Check that method override is compatible with base class Signature of "read_records" incompatible with supertype "GoogleAdsStream" . Code line: def read_records(
python:S3776 (CRITICAL) source_google_ads/streams.py:143 Cognitive Complexity of functions should not be too high Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
python:mypy_arg_type (MINOR) source_google_ads/streams.py:159 Check argument types in calls Argument 1 to "get_updated_state" of "IncrementalGoogleAdsStream" has incompatible type "Mapping[str, Any]"; expected "MutableMapping[str, Any]" . Code line: state = self.get_updated_state(state, record)
python:S1871 (MAJOR) source_google_ads/streams.py:172 Two branches in a conditional structure should not have exactly the same implementation Either merge this branch with the identical one on line "167" or change one of the implementations.
python:mypy_no_untyped_def (MINOR) unit_tests/common.py:15 Check that every function has an annotation Function is missing a type annotation . Code line: def search(self, search_request):
python:mypy_no_untyped_def (MINOR) unit_tests/common.py:20 Check that every function has an annotation Function is missing a type annotation . Code line: def init(self, config):
python:mypy_no_untyped_def (MINOR) unit_tests/common.py:23 Check that every function has an annotation Function is missing a type annotation . Code line: def get_type(self, type):
python:mypy_no_untyped_def (MINOR) unit_tests/common.py:26 Check that every function has an annotation Function is missing a type annotation . Code line: def get_service(self, service):
python:mypy_no_untyped_def (MINOR) unit_tests/common.py:30 Check that every function has an annotation Function is missing a type annotation . Code line: def load_from_dict(config):
python:isort_need_format (MINOR) unit_tests/test_google_ads.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:isort_need_format (MINOR) unit_tests/test_source.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:S2638 (CRITICAL) unit_tests/test_streams.py Method overrides should not change contracts Add missing parameters customer_id.
python:isort_need_format (MINOR) unit_tests/test_streams.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:S1192 (CRITICAL) unit_tests/test_streams.py:52 String literals should not be duplicated Define a constant instead of duplicating this literal "click_view.gclid" 21 times.
python:S1192 (CRITICAL) unit_tests/test_streams.py:52 String literals should not be duplicated Define a constant instead of duplicating this literal "segments.date" 24 times.
python:S930 (BLOCKER) unit_tests/test_google_ads.py The number and name of arguments passed to a function should match its parameters Add 1 missing arguments; 'send_request' expects 2 positional arguments.
python:mypy_no_untyped_def (MINOR) source_google_ads/streams.py:110 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def init(self, start_date: str, conversion_window_days: int, t...
python:S5655 (CRITICAL) unit_tests/test_source.py:20 Arguments given to functions should be of an expected type Change this argument; Function "chunk_date_range" expects a different type
python:S5655 (CRITICAL) unit_tests/test_source.py:20 Arguments given to functions should be of an expected type Change this argument; Function "chunk_date_range" expects a different type
python:S1192 (CRITICAL) unit_tests/test_source.py:102 String literals should not be duplicated Define a constant instead of duplicating this literal "segments.date" 11 times.
python:S1192 (CRITICAL) unit_tests/test_source.py:282 String literals should not be duplicated Define a constant instead of duplicating this literal "campaign.end_date" 3 times.
flake8:E501 (MAJOR) source_google_ads/streams.py:108 line too long (82 > 79 characters) line too long (166 > 140 characters)
python:S112 (MAJOR) source_google_ads/source.py:82 "Exception" and "BaseException" should not be raised Replace this generic exception class with a more specific one.
python:mypy_no_untyped_def (MINOR) source_google_ads/source.py:48 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def get_account_info(google_api) -> dict:
python:mypy_no_any_return (MINOR) source_google_ads/source.py:49 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "Dict[Any, Any]" . Code line: return next(Accounts(api=google_api).read_records(sync_mode=No...
python:mypy_call_overload (MINOR) source_google_ads/source.py:49 Check that an overload variant matches arguments No overload variant of "next" matches argument types "Iterable[Mapping[str, Any]]", "Dict[, ]" . Code line: return next(Accounts(api=google_api).read_records(sync_mode=No...
python:mypy_valid_type (MINOR) source_google_ads/source.py:52 Check that type (annotation) is valid Function "pendulum.tz.timezone" is not valid as a type . Code line: def get_time_zone(account: dict) -> Union[timezone, str]:
python:mypy_attr_defined (MINOR) source_google_ads/google_ads.py:92 Check that attribute exists Module has no attribute "parse" . Code line: end_date_inclusive = "<=" if (pendulum.parse(to_date) - pe...
python:mypy_no_untyped_def (MINOR) source_google_ads/streams.py:43 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def chunk_date_range(
python:mypy_valid_type (MINOR) source_google_ads/streams.py:51 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ) -> Iterable[Mapping[str, any]]:
python:mypy_assignment (MINOR) source_google_ads/streams.py:305 Check that assigned value is compatible with target Incompatible types in assignment (expression has type "int", base class "IncrementalGoogleAdsStream" defined the type as "None") . Code line: days_of_data_storage = 90
python:isort_need_format (MINOR) main.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:mypy_no_untyped_def (MINOR) source_google_ads/custom_query_stream.py:13 Check that every function has an annotation Function is missing a type annotation . Code line: def init(self, custom_query_config, **kwargs):
python:mypy_override (MINOR) source_google_ads/custom_query_stream.py:19 Check that method override is compatible with base class Signature of "primary_key" incompatible with supertype "IncrementalGoogleAdsStream" . Code line: def primary_key(self) -> str:
python:S125 (MAJOR) source_google_ads/custom_query_stream.py:25 Sections of code should not be commented out Remove this commented out code.
python:S5886 (MAJOR) source_google_ads/custom_query_stream.py:26 Function return types should be consistent with their type hint Return a value of type "str" instead of "NoneType" or update function "primary_key" type hint.
python:mypy_no_untyped_def (MINOR) source_google_ads/custom_query_stream.py:29 Check that every function has an annotation Function is missing a return type annotation . Code line: def name(self):
python:mypy_dict_item (MINOR) source_google_ads/custom_query_stream.py:80 Check dict items in a dict expression {key: value, ...} Dict entry 1 has incompatible type "str": "bool"; expected "str": "Sequence[Any]" . Code line: ... field_value = {"type": output_type, "protobuf_message": T...
python:mypy_index (MINOR) source_google_ads/custom_query_stream.py:87 Check indexing operations Unsupported target for indexed assignment ("object") . Code line: local_json_schema["properties"][field] = field_value
python:S112 (MAJOR) source_google_ads/custom_query_stream.py:120 "Exception" and "BaseException" should not be raised Replace this generic exception class with a more specific one.
flake8:E203 (MAJOR) source_google_ads/custom_query_stream.py:145 whitespace before ‘:’ whitespace before ':'
python:S930 (BLOCKER) source_google_ads/source.py The number and name of arguments passed to a function should match its parameters Add 1 missing arguments; 'send_request' expects 2 positional arguments.
python:mypy_call_arg (MINOR) source_google_ads/source.py Check number, names and kinds of arguments in calls Missing positional argument "customer_id" in call to "send_request" of "GoogleAds" . Code line: google_api.send_request(req_q)
python:S112 (MAJOR) source_google_ads/source.py:84 "Exception" and "BaseException" should not be raised Replace this generic exception class with a more specific one.
flake8:E501 (MAJOR) unit_tests/test_source.py:257 line too long (82 > 79 characters) line too long (142 > 140 characters)
flake8:E501 (MAJOR) unit_tests/test_google_ads.py:147 line too long (82 > 79 characters) line too long (147 > 140 characters)
python:mypy_no_any_return (MINOR) source_google_ads/source.py:45 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "Mapping[str, Any]" . Code line: return credentials
flake8:E501 (MAJOR) source_google_ads/google_ads.py:159 line too long (82 > 79 characters) line too long (165 > 140 characters)
flake8:E501 (MAJOR) source_google_ads/google_ads.py:160 line too long (82 > 79 characters) line too long (173 > 140 characters)
python:mypy_attr_defined (MINOR) source_google_ads/streams.py:58 Check that attribute exists Module has no attribute "parse" . Code line: end_date = pendulum.parse(end_date) if end_date else pendulum.now(...
python:mypy_attr_defined (MINOR) source_google_ads/streams.py:59 Check that attribute exists Module has no attribute "parse" . Code line: start_date = pendulum.parse(start_date)
python:mypy_no_untyped_def (MINOR) source_google_ads/streams.py:97 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def read_records(self, sync_mode, stream_slice: Mapping[str, Any] ...
python:mypy_no_untyped_def (MINOR) source_google_ads/streams.py:117 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def stream_slices(self, stream_state: Mapping[str, Any] = None, **...
python:mypy_valid_type (MINOR) source_google_ads/streams.py:117 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...[str, Any] = None, **kwargs) -> Iterable[Optional[Mapping[str, any]]]:
python:mypy_attr_defined (MINOR) source_google_ads/streams.py:195 Check that attribute exists Module has no attribute "parse" . Code line: date_in_latest_record = pendulum.parse(latest_record[self.curs...
python:mypy_valid_type (MINOR) source_google_ads/source.py:70 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
python:mypy_no_untyped_def (MINOR) integration_tests/acceptance.py:12 Check that every function has an annotation Function is missing a return type annotation . Code line: def connector_setup():
python:S3776 (CRITICAL) integration_tests/test_incremental.py:50 Cognitive Complexity of functions should not be too high Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed.
python:mypy_no_any_return (MINOR) source_google_ads/google_ads.py:173 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "str" . Code line: return field_value
python:mypy_no_untyped_def (MINOR) source_google_ads/google_ads.py:176 Check that every function has an annotation Function is missing a return type annotation . Code line: def parse_single_result(schema: Mapping[str, Any], result: GoogleA...
python:S1192 (CRITICAL) unit_tests/test_google_ads.py:17 String literals should not be duplicated Define a constant instead of duplicating this literal "segment.date" 3 times.
python:S1764 (MAJOR) unit_tests/test_google_ads.py:162 Identical expressions should not be used on both sides of a binary operator Correct one of the identical sub-expressions on both sides of operator "==".

Coverage (21.4%)

File Coverage File Coverage
integration_tests/acceptance.py 0.0 integration_tests/conftest.py 0.0
integration_tests/test_incremental.py 0.0 main.py 0.0
setup.py 0.0 source_google_ads/init.py 100.0
source_google_ads/custom_query_stream.py 60.8 source_google_ads/google_ads.py 80.0
source_google_ads/source.py 48.5 source_google_ads/streams.py 84.3
unit_tests/common.py 0.0 unit_tests/conftest.py 0.0
unit_tests/test_google_ads.py 0.0 unit_tests/test_source.py 0.0
unit_tests/test_streams.py 0.0

Please sign in to comment.